本文整理汇总了C++中Document::End方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::End方法的具体用法?C++ Document::End怎么用?C++ Document::End使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document::End方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nameArrayFromData
std::vector<name_t> nameArrayFromData(const char *jsonData, size_t len) {
std::vector<char> buffer(len + 1);
std::memcpy(&buffer[0], jsonData, len);
Document doc;
doc.ParseInsitu(&buffer[0]);
assert(doc.IsArray());
std::vector<name_t> nameArray;
nameArray.reserve(doc.Size());
for( auto array_item = doc.Begin(); array_item != doc.End(); array_item++ ) {
name_t instance = name_t(*array_item);
nameArray.push_back(instance);
}
return nameArray;
}
示例2: if
/* ****************************************************************************
*
* parseContextAttributeCompoundValueStandAlone -
*/
std::string parseContextAttributeCompoundValueStandAlone
(
Document& document,
ContextAttribute* caP,
orion::ValueType valueType
)
{
caP->compoundValueP = new orion::CompoundValueNode();
caP->compoundValueP->name = "TOP";
caP->compoundValueP->container = caP->compoundValueP;
caP->compoundValueP->valueType = caP->valueType; // Convert to other type?
caP->compoundValueP->path = "/";
caP->compoundValueP->rootP = caP->compoundValueP;
caP->compoundValueP->level = 0;
caP->compoundValueP->siblingNo = 0;
orion::CompoundValueNode* parent = caP->compoundValueP;
//
// Children of the node
//
if (caP->valueType == orion::ValueTypeVector)
{
int counter = 0;
for (Value::ConstValueIterator iter = document.Begin(); iter != document.End(); ++iter)
{
std::string nodeType = jsonParseTypeNames[iter->GetType()];
orion::CompoundValueNode* cvnP = new orion::CompoundValueNode();
char itemNo[4];
snprintf(itemNo, sizeof(itemNo), "%03d", counter);
cvnP->valueType = stringToCompoundType(nodeType);
cvnP->container = parent;
cvnP->rootP = parent->rootP;
cvnP->level = parent->level + 1;
cvnP->siblingNo = counter;
cvnP->path = parent->path + "[" + itemNo + "]";
if (nodeType == "String")
{
cvnP->stringValue = iter->GetString();
}
else if (nodeType == "Number")
{
cvnP->numberValue = iter->GetDouble();
}
else if ((nodeType == "True") || (nodeType == "False"))
{
cvnP->boolValue = (nodeType == "True")? true : false;
}
else if (nodeType == "Null")
{
cvnP->valueType = orion::ValueTypeNone;
}
else if (nodeType == "Object")
{
cvnP->path += "/";
cvnP->valueType = orion::ValueTypeObject;
}
else if (nodeType == "Array")
{
cvnP->path += "/";
cvnP->valueType = orion::ValueTypeVector;
}
parent->childV.push_back(cvnP);
//
// Start recursive calls if Object or Array
//
if ((nodeType == "Object") || (nodeType == "Array"))
{
parseContextAttributeCompoundValue(iter, caP, cvnP);
}
else if (!caP->typeGiven)
{
caP->type = defaultType(caP->valueType);
}
++counter;
}
}
else if (caP->valueType == orion::ValueTypeObject)
{
int counter = 0;
for (Value::ConstMemberIterator iter = document.MemberBegin(); iter != document.MemberEnd(); ++iter)
{
std::string nodeType = jsonParseTypeNames[iter->value.GetType()];
orion::CompoundValueNode* cvnP = new orion::CompoundValueNode();
cvnP->name = iter->name.GetString();
//.........这里部分代码省略.........
示例3: serializer
BOOST_FIXTURE_TEST_CASE( types , BaseFixture ) {
MOSerializer serializer(&db);
StringBuffer buffer;
Writer<StringBuffer> writer(buffer);
StoreClient& sysClient = db.getStoreClient("_SYSTEM_");
URI c2u("/class2/32/");
URI c4u("/class4/test/");
URI c5u("/class5/test/");
URI c6u("/class4/test/class6/test2/");
URI c7u("/class4/test/class7/0");
shared_ptr<ObjectInstance> oi1 = make_shared<ObjectInstance>(1);
shared_ptr<ObjectInstance> oi2 = make_shared<ObjectInstance>(2);
shared_ptr<ObjectInstance> oi4 = make_shared<ObjectInstance>(4);
shared_ptr<ObjectInstance> oi5 = make_shared<ObjectInstance>(5);
shared_ptr<ObjectInstance> oi6 = make_shared<ObjectInstance>(6);
shared_ptr<ObjectInstance> oi7 = make_shared<ObjectInstance>(7);
oi2->setInt64(4, 32);
oi2->setMAC(15, MAC("aa:bb:cc:dd:ee:ff"));
oi5->setString(10, "test");
oi5->addReference(11, 4, c4u);
oi4->setString(9, "test");
oi6->setString(13, "test2");
oi7->setUInt64(14, 0);
sysClient.put(1, URI::ROOT, oi1);
sysClient.put(2, c2u, oi2);
sysClient.put(4, c4u, oi4);
sysClient.put(5, c5u, oi5);
sysClient.put(6, c6u, oi6);
sysClient.put(7, c7u, oi7);
sysClient.addChild(1, URI::ROOT, 3, 2, c2u);
sysClient.addChild(1, URI::ROOT, 8, 4, c4u);
sysClient.addChild(1, URI::ROOT, 24, 5, c5u);
sysClient.addChild(4, c4u, 12, 6, c6u);
sysClient.addChild(4, c4u, 25, 7, c7u);
writer.StartArray();
serializer.serialize(1, URI::ROOT, sysClient, writer);
writer.EndArray();
string str(buffer.GetString());
//std::cerr << str << std::endl;
sysClient.remove(1, URI::ROOT, true);
BOOST_CHECK_THROW(sysClient.get(1, URI::ROOT), out_of_range);
BOOST_CHECK_THROW(sysClient.get(2, c2u), out_of_range);
BOOST_CHECK_THROW(sysClient.get(4, c4u), out_of_range);
BOOST_CHECK_THROW(sysClient.get(5, c5u), out_of_range);
BOOST_CHECK_THROW(sysClient.get(6, c6u), out_of_range);
BOOST_CHECK_THROW(sysClient.get(7, c7u), out_of_range);
Document d;
d.Parse(str.c_str());
Value::ConstValueIterator it;
for (it = d.Begin(); it != d.End(); ++it) {
serializer.deserialize(*it, sysClient, true, NULL);
}
BOOST_CHECK_EQUAL("test", sysClient.get(4, c4u)->getString(9));
BOOST_CHECK_EQUAL("test", sysClient.get(5, c5u)->getString(10));
BOOST_CHECK(make_pair((class_id_t)4ul, c4u) ==
sysClient.get(5, c5u)->getReference(11, 0));
BOOST_CHECK_EQUAL("test2", sysClient.get(6, c6u)->getString(13));
BOOST_CHECK_EQUAL(0, sysClient.get(7, c7u)->getUInt64(14));
BOOST_CHECK_EQUAL(MAC("aa:bb:cc:dd:ee:ff"), sysClient.get(2, c2u)->getMAC(15));
}
示例4: GetEPGForChannelExternalService
void ZatData::GetEPGForChannelExternalService(int uniqueChannelId, time_t iStart, time_t iEnd)
{
ZatChannel *zatChannel = FindChannel(uniqueChannelId);
string cid = zatChannel->cid;
ostringstream urlStream;
urlStream << "http://zattoo.buehlmann.net/epg/api/Epg/" << countryCode << "/"
<< powerHash << "/" << cid << "/" << iStart << "/" << iEnd;
string jsonString = HttpGet(urlStream.str());
Document doc;
doc.Parse(jsonString.c_str());
if (doc.GetParseError())
{
return;
}
for (Value::ConstValueIterator itr = doc.Begin(); itr != doc.End(); ++itr)
{
const Value& program = (*itr);
EPG_TAG tag;
memset(&tag, 0, sizeof(EPG_TAG));
tag.iUniqueBroadcastId = program["Id"].GetInt();
string title = program["Title"].GetString();
tag.strTitle = title.c_str();
tag.iUniqueChannelId = zatChannel->iUniqueId;
tag.startTime = StringToTime(program["StartTime"].GetString());
tag.endTime = StringToTime(program["EndTime"].GetString());
string description = program["Description"].GetString();
tag.strPlotOutline = description.c_str();
tag.strPlot = description.c_str();
tag.strOriginalTitle = NULL; /* not supported */
tag.strCast = NULL; /* not supported */
tag.strDirector = NULL; /*SA not supported */
tag.strWriter = NULL; /* not supported */
tag.iYear = 0; /* not supported */
tag.strIMDBNumber = NULL; /* not supported */
string imageUrl =
program["ImageUrl"].IsString() ? program["ImageUrl"].GetString() : "";
tag.strIconPath = imageUrl.c_str();
tag.iParentalRating = 0; /* not supported */
tag.iStarRating = 0; /* not supported */
tag.bNotify = false; /* not supported */
tag.iSeriesNumber = 0; /* not supported */
tag.iEpisodeNumber = 0; /* not supported */
tag.iEpisodePartNumber = 0; /* not supported */
string subTitle =
program["Subtitle"].IsString() ? program["Subtitle"].GetString() : "";
tag.strEpisodeName = subTitle.c_str(); /* not supported */
tag.iFlags = EPG_TAG_FLAG_UNDEFINED;
string genreStr =
program["Genre"].IsString() ? program["Genre"].GetString() : "";
int genre = categories.Category(genreStr.c_str());
if (genre)
{
tag.iGenreSubType = genre & 0x0F;
tag.iGenreType = genre & 0xF0;
}
else
{
tag.iGenreType = EPG_GENRE_USE_STRING;
tag.iGenreSubType = 0; /* not supported */
tag.strGenreDescription = genreStr.c_str();
}
PVR->EpgEventStateChange(&tag, EPG_EVENT_CREATED);
}
return;
}