本文整理汇总了C++中ValueArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueArray::Add方法的具体用法?C++ ValueArray::Add怎么用?C++ ValueArray::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueArray
的用法示例。
在下文中一共展示了ValueArray::Add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: min
void ValueMap::Data::Jsonize(JsonIO& jio)
{
if(jio.IsStoring()) {
ValueArray va;
int n = min(value.GetCount(), key.GetCount());
for(int i = 0; i < n; i++) {
ValueMap m;
m.Add("key", StoreAsJsonValue(key[i]));
m.Add("value", StoreAsJsonValue(value[i]));
va.Add(m);
}
jio.Set(va);
}
else {
Value va = jio.Get();
key.Clear();
value.Clear();
for(int i = 0; i < va.GetCount(); i++) {
Value k, v;
LoadFromJsonValue(k, va[i]["key"]);
LoadFromJsonValue(v, va[i]["value"]);
key.Add(k);
value.Add(v);
}
}
}
示例2: MacroMenu
void Ide::MacroMenu(Bar& menu)
{
const Array<IdeMacro>& mlist = UscMacros();
if(!mlist.IsEmpty() && menu.IsMenuBar()) {
VectorMap< String, Vector<int> > submenu_map;
for(int i = 0; i < mlist.GetCount(); i++) {
const IdeMacro& m = mlist[i];
if(!IsNull(m.menu)) {
if(IsNull(m.submenu))
submenu_map.GetAdd(Null).Add(i);
else
submenu_map.GetAdd(m.menu).Add(i);
}
}
if(!submenu_map.IsEmpty()) {
Vector<int> order = GetSortOrder(submenu_map.GetKeys());
for(int o = 0; o < order.GetCount(); o++) {
String m = submenu_map.GetKey(order[o]);
Vector<int>& mx = submenu_map[order[o]];
ValueArray va;
for(int i = 0; i < mx.GetCount(); i++)
va.Add(mx[i]);
if(!IsNull(m))
menu.Add(m, THISBACK1(EditMacroMenu, va));
else
EditMacroMenu(menu, va);
}
}
}
}
示例3:
Value Compiler::ExeArray::Eval(ExeContext& x) const
{
ValueArray va;
for(int i = 0; i < item.GetCount(); i++)
va.Add(item[i]->Eval(x));
return va;
}
示例4: FetchResults
ValueArray Client::FetchResults(const CommitFilter& f) const {
SQLR * Select(SqlAll(RESULT),
DT, CMT, BRANCH,
UID, ToSqlVal(Regexp(PATH,data["SRC"])).As("FITS"))
.From(COMMITS)
.LeftJoin(RESULT).On(UID == CMT_UID && CLIENT_ID == data["ID"])
.Where(f)
.OrderBy(Descending(DT))
.Limit(f.offset, f.limit);
ValueArray res;
ValueMap vm;
Time t = GetUtcTime();
int maxage = int(data["MAX_AGE"])*24*60*60;
while(SQLR.Fetch(vm)){
SetComputedAttributes(vm);
SetDuration(vm, vm["STATUS"]);
if (IsNull(vm["STATUS"])) {
if (!vm["FITS"])
vm.Set("STATUSSTR", "Not interested");
else if (t-Time(vm["DT"]) > maxage)
vm.Set("STATUSSTR", "Too old");
else
vm.Set("STATUSSTR", "Ready");
}
res.Add(vm);
}
return res;
}
示例5: ParseXmlRpcParams
ValueArray ParseXmlRpcParams(XmlParser& p)
{
ValueArray va;
if(p.Tag("params"))
while(!p.End())
va.Add(ParseXmlRpcParam(p));
return va;
}
示例6: ParseArray
/**
* parse the special value "array". this method parses the complexer value "array" and returns it
* @param p XmlParser holding the xml document
* @return the parsed array as Value (not ValueArray!)
*/
Value XmlRpcParser::ParseArray(XmlParser& p) {
ValueArray va;
p.PassTag("data");
while(!p.End()) {
Value v = Parse(p);
va.Add(v);
}
return Value(va);
}
示例7: Format
Value FormatConvert::Format(const Value& v) const
{
ValueArray va;
if(IsValueArray(v))
va = v;
else
va.Add(v);
return UPP::Format(format, va.Get());
}
示例8:
ValueArray Sql::operator/(const SqlStatement& q)
{
ValueArray va;
Execute(q);
ValueMap m;
while(Fetch(m))
va.Add(m);
return va;
}
示例9: ParseJSON
NAMESPACE_UPP
Value ParseJSON(CParser& p)
{
p.UnicodeEscape();
if(p.IsDouble())
return p.ReadDouble();
if(p.IsString()) {
bool dt = p.IsChar2('\"', '\\');
String s = p.ReadString();
if(dt) {
CParser p(s);
if(p.Char('/') && p.Id("Date") && p.Char('(') && p.IsInt()) {
int64 n = p.ReadInt64();
if(!IsNull(n))
return Time(1970, 1, 1) + n / 1000;
}
}
return s;
}
if(p.Id("null"))
return Null;
if(p.Id("true"))
return true;
if(p.Id("false"))
return false;
if(p.Char('{')) {
ValueMap m;
while(!p.Char('}')) {
String key = p.ReadString();
p.PassChar(':');
m.Add(key, ParseJSON(p));
if(p.Char('}')) // Stray ',' at the end of list is allowed...
break;
p.PassChar(',');
}
return m;
}
if(p.Char('[')) {
ValueArray va;
while(!p.Char(']')) {
va.Add(ParseJSON(p));
if(p.Char(']')) // Stray ',' at the end of list is allowed...
break;
p.PassChar(',');
}
return va;
}
p.ThrowError("Unrecognized JSON element");
return Null;
}
示例10: ParseMethodCall
/**
* parse a method call. it parses a xml message sent by a client and returns the method name and
* the parameter it contains.
* @param s the received data
* @return the value, which includes an ValueArray with first element beeing the method name
* @see ParseMethodResponse()
*/
Value XmlRpcParser::ParseMethodCall(String s){
XmlParser p(s);
ValueArray va;
try {
while(!p.Tag("methodCall"))
p.Skip();
p.PassTag("methodName");
va.Add(Value(p.ReadText()));
p.PassEnd(); //methodName
p.PassTag("params");
while(p.Tag("param")) {
va.Add(Parse(p));
p.PassEnd(); //param
}
p.PassEnd(); //params
p.PassEnd(); //methodCall
LOG("request parsed");
} catch(Exc e) {
return ErrorValue(NFormat("EXCEPTION: %s",e));
}
return Value(va);
}
示例11: LoadPage
ValueArray Commit::LoadPage(const CommitFilter& f) {
SQLR * Select(SqlAll(),
CountIf(1, STATUS==WD_INPROGRESS).As("RUNNING"),
SqlFunc("sum",OK).As("OK"),
SqlFunc("sum",FAIL).As("FAIL"),
SqlFunc("sum",ERR).As("ERR"),
SqlFunc("sum",SKIP).As("SKIP"))
.From(COMMITS)
.LeftJoin(RESULT).On(UID==CMT_UID)
.Where(f)
.GroupBy(UID)
.OrderBy(Descending(DT))
.Limit(f.offset, f.limit);
ValueArray res;
ValueMap vm;
while (SQLR.Fetch(vm)){
SetComputedAttributes(vm);
res.Add(vm);
}
return res;
}
示例12: ParseJSON
NAMESPACE_UPP
Value ParseJSON(CParser& p)
{
p.UnicodeEscape();
if(p.IsNumber())
return p.ReadDouble();
if(p.IsString())
return p.ReadString();
if(p.Id("null"))
return Null;
if(p.Id("true"))
return true;
if(p.Id("false"))
return false;
if(p.Char('{')) {
ValueMap m;
if(!p.IsChar('}'))
do {
String key = p.ReadString();
p.PassChar(':');
m.Add(key, ParseJSON(p));
}
while(p.Char(','));
p.PassChar('}');
return m;
}
if(p.Char('[')) {
ValueArray va;
if(!p.IsChar(']'))
do
va.Add(ParseJSON(p));
while(p.Char(','));
p.PassChar(']');
return va;
}
p.ThrowError("Unrecognized JSON element");
return Null;
}
示例13: ParseXmlRpcValue
NAMESPACE_UPP
Value ParseXmlRpcValue(XmlParser& p)
{
Value r;
p.PassTag("value");
if(p.Tag("int") || p.Tag("i4")) {
String s = p.ReadText();
CParser p(s);
if(!p.IsInt())
throw XmlError("integer expected");
r = p.ReadInt();
}
else
if(p.Tag("boolean")) {
int n = StrInt(p.ReadText());
if(n != 0 && n != 1)
throw XmlError("boolean expected");
r = (bool)n;
}
else
if(p.Tag("double")) {
String s = p.ReadText();
CParser p(s);
if(!p.IsDouble())
throw XmlError("double expected");
r = p.ReadDouble();
}
else
if(p.Tag("string") || p.Tag("base64"))
r = p.ReadText();
else
if(p.TagE("nil")) {
p.PassEnd();
return r;
}
else
if(p.Tag("dateTime.iso8601")) {
String s = TrimBoth(p.ReadText());
// 19980717T14:08:55
// 01234567890123456
if(s.GetCount() != 17 || s[8] != 'T' || s[11] != ':' || s[14] != ':')
throw XmlError("invalid dateTime format");
Time tm;
tm.year = atoi(s.Mid(0, 4));
tm.month = atoi(s.Mid(4, 2));
tm.day = atoi(s.Mid(6, 2));
tm.hour = atoi(s.Mid(9, 2));
tm.minute = atoi(s.Mid(12, 2));
tm.second = atoi(s.Mid(15, 2));
r = tm;
}
else
if(p.Tag("array")) {
ValueArray va;
p.PassTag("data");
while(!p.End())
va.Add(ParseXmlRpcValue(p));
r = va;
}
else
if(p.Tag("struct")) {
ValueMap vm;
while(p.Tag("member")) {
p.PassTag("name");
String name = p.ReadText();
p.PassEnd();
vm.Add((Value)name, ParseXmlRpcValue(p));
p.PassEnd();
}
r = vm;
}
else
throw XmlError("unknown value type");
p.PassEnd();
p.PassEnd();
return r;
}