本文整理汇总了C++中ValueArray类的典型用法代码示例。如果您正苦于以下问题:C++ ValueArray类的具体用法?C++ ValueArray怎么用?C++ ValueArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ValueArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckValueMap
void CheckValueMap()
{
RLOG("------------------------------");
RLOG("CheckValueMap");
Value x = 123;
Value y = x;
ValueMap h;
h.Add("0", 123);
RDUMP(h["0"]);
h.Add("1", Date(2001, 12, 1));
h.Add("2", "test");
Value v = h;
ASSERT(v.GetCount() == 3);
RDUMP(v["0"]);
ASSERT(v["0"] == 123);
ASSERT(v["1"] == Date(2001, 12, 1));
ASSERT(v["2"] == "test");
ASSERT(IsValueMap(v));
ASSERT(IsValueArray(v));
ValueMap hh = v;
ASSERT(hh == h);
hh.Add(123, "foo");
ASSERT(hh.GetCount() == 4);
ASSERT(v.GetCount() == 3);
ASSERT(hh[123] == "foo");
ValueArray va = v;
ASSERT(va.GetCount() == 3);
ASSERT(va[0] == 123);
ASSERT(va[1] == Date(2001, 12, 1));
ASSERT(va[2] == "test");
}
示例2: test_set_diff
void test_set_diff(Ardb& db)
{
DBID dbid = 0;
db.SClear(dbid, "myset1");
db.SClear(dbid, "myset2");
db.SClear(dbid, "myset3");
db.SAdd(dbid, "myset1", "a");
db.SAdd(dbid, "myset1", "b");
db.SAdd(dbid, "myset1", "c");
db.SAdd(dbid, "myset1", "d");
db.SAdd(dbid, "myset2", "c");
db.SAdd(dbid, "myset3", "a");
db.SAdd(dbid, "myset3", "c");
db.SAdd(dbid, "myset3", "e");
std::string str;
SliceArray keys;
keys.push_back("myset1");
keys.push_back("myset2");
keys.push_back("myset3");
ValueArray values;
db.SDiff(dbid, keys, values);
CHECK_FATAL(values.size() != 2, "Sdiff failed:");
CHECK_FATAL(values.begin()->ToString(str) != "b", "Sdiff store failed:");
//CHECK_FATAL(FATAL, values[1] != "d") << "Sdiff store failed:";
int len = db.SDiffStore(dbid, "myset2", keys);
CHECK_FATAL(len != 2, "SDiffStore myset2 failed:%d", len);
len = db.SCard(dbid, "myset2");
CHECK_FATAL(len != 2, "SDiffStore myset2 failed:%d", len);
}
示例3: test_set_inter
void test_set_inter(Ardb& db)
{
DBID dbid = 0;
db.SClear(dbid, "myset1");
db.SClear(dbid, "myset2");
db.SClear(dbid, "myset3");
db.SAdd(dbid, "myset1", "a");
db.SAdd(dbid, "myset1", "b");
db.SAdd(dbid, "myset1", "c");
db.SAdd(dbid, "myset1", "d");
db.SAdd(dbid, "myset2", "c");
db.SAdd(dbid, "myset3", "a");
db.SAdd(dbid, "myset3", "c");
db.SAdd(dbid, "myset3", "e");
SliceArray keys;
keys.push_back("myset1");
keys.push_back("myset2");
keys.push_back("myset3");
ValueArray values;
db.SInter(dbid, keys, values);
std::string str;
CHECK_FATAL( values.size() != 1, "Sinter failed:");
CHECK_FATAL(values.begin()->ToString(str) != "c", "Sinter store failed.");
db.SInterStore(dbid, "myset4", keys);
CHECK_FATAL( db.SCard(dbid, "myset4") != 1, "SInterStore myset4 failed");
}
示例4:
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;
}
示例5: test_set_union
void test_set_union(Ardb& db)
{
DBID dbid = 0;
db.SClear(dbid, "myset1");
db.SClear(dbid, "myset2");
db.SClear(dbid, "myset3");
db.SAdd(dbid, "myset1", "a");
db.SAdd(dbid, "myset1", "b");
db.SAdd(dbid, "myset1", "c");
db.SAdd(dbid, "myset1", "d");
db.SAdd(dbid, "myset2", "c");
db.SAdd(dbid, "myset3", "a");
db.SAdd(dbid, "myset3", "c");
db.SAdd(dbid, "myset3", "e");
SliceArray keys;
keys.push_back("myset1");
keys.push_back("myset2");
keys.push_back("myset3");
ValueArray values;
db.SUnion(dbid, keys, values);
CHECK_FATAL(values.size() != 5, "SUnion failed:");
std::string str;
CHECK_FATAL( values.begin()->ToString(str) != "a", "SUnion store failed:");
db.SUnionStore(dbid, "myset2", keys);
CHECK_FATAL(db.SCard(dbid, "myset2") != 5, "SUnionStore myset2 failed:");
}
示例6: Select
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;
}
示例7: UscMacros
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);
}
}
}
}
示例8: 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);
}
}
}
示例9: EscFromStdValue
EscValue EscFromStdValue(const Value& v)
{
EscValue r;
Time t;
if(!IsNull(v))
switch(v.GetType()) {
case BOOL_V:
case INT_V:
case INT64_V:
case DOUBLE_V:
r = (double)v;
break;
case STRING_V:
case WSTRING_V:
r = (WString)v;
break;
case TIME_V:
t = v;
r.MapSet("hour", t.hour);
r.MapSet("minute", t.minute);
r.MapSet("second", t.second);
case DATE_V:
t = v;
r.MapSet("year", t.year);
r.MapSet("month", t.month);
r.MapSet("day", t.day);
break;
case VALUEARRAY_V:
ValueArray va = v;
r.SetEmptyArray();
for(int i = 0; i < va.GetCount(); i++)
r.ArrayAdd(EscFromStdValue(va[i]));
}
return r;
}
示例10: ParseXmlRpcParams
ValueArray ParseXmlRpcParams(XmlParser& p)
{
ValueArray va;
if(p.Tag("params"))
while(!p.End())
va.Add(ParseXmlRpcParam(p));
return va;
}
示例11: ValueArray
CountPtr<Value> ValueArray::iterator(void) const
{
ValueArray* tmp = new ValueArray();
tmp->m_val = m_val;
tmp->resetIterator();
return CountPtr<Value>(tmp);
}
示例12:
ValueArray Sql::operator/(const SqlStatement& q)
{
ValueArray va;
Execute(q);
ValueMap m;
while(Fetch(m))
va.Add(m);
return va;
}
示例13: 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);
}
示例14: 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());
}
示例15: selfTemplateArgs
ValueArray Alias::selfTemplateArgs() const {
ValueArray templateArgs;
templateArgs.reserve(templateVariables().size());
for (const auto templateVar: templateVariables()) {
// Refer to the template variables of this type alias.
templateArgs.push_back(templateVar->selfRefValue());
}
return templateArgs;
}