本文整理汇总了C++中Document::MemberEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::MemberEnd方法的具体用法?C++ Document::MemberEnd怎么用?C++ Document::MemberEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document::MemberEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetTitleInfo
/// <summary>
/// PlayFab Title cannot be created from SDK tests, so you must provide your titleId to run unit tests.
/// (Also, we don't want lots of excess unused titles)
/// </summary>
bool SetTitleInfo(Document &testInputs)
{
CCLOG("%s", "SetTitleInfo");
// Parse all the inputs
auto end = testInputs.MemberEnd();
auto each = testInputs.FindMember("titleId");
if (each != end) PlayFabSettings::titleId = each->value.GetString(); else return false;
each = testInputs.FindMember("developerSecretKey");
if (each != end) PlayFabSettings::developerSecretKey = each->value.GetString(); else return false;
string blah;
each = testInputs.FindMember("titleCanUpdateSettings");
if (each != end) blah = each->value.GetString(); else return false;
TITLE_CAN_UPDATE_SETTINGS = (blah.compare("true") == 0 || blah.compare("True") == 0 || blah.compare("TRUE") == 0);
each = testInputs.FindMember("userName");
if (each != end) USER_NAME = each->value.GetString(); else return false;
each = testInputs.FindMember("userEmail");
if (each != end) USER_EMAIL = each->value.GetString(); else return false;
each = testInputs.FindMember("userPassword");
if (each != end) USER_PASSWORD = each->value.GetString(); else return false;
each = testInputs.FindMember("characterName");
if (each != end) CHAR_NAME = each->value.GetString(); else return false;
// Verify all the inputs won't cause crashes in the tests
return !PlayFabSettings::titleId.empty()
&& !PlayFabSettings::developerSecretKey.empty()
&& !USER_NAME.empty()
&& !USER_EMAIL.empty()
&& !USER_PASSWORD.empty()
&& !CHAR_NAME.empty();
}
示例2: OnReadStats
LRESULT Cdispatcher_uiDlg::OnReadStats(WPARAM wparam, LPARAM lParam) {
char *buf = (char*)wparam;
Document d;
if (d.Parse(buf).HasParseError()) {
int unicodeLen = MultiByteToWideChar(CP_ACP, 0, buf, -1, 0, 0);
wchar_t *wc = new wchar_t[unicodeLen+1];
memset(wc, 0, (unicodeLen + 1)*sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, buf, -1, wc, unicodeLen);
m_static_msg.SetWindowText(wc);
delete[]wc;
}
else {
//read/stats
uint64_t count_service = 0;
uint64_t count_dispatch = 0;
for (Value::ConstMemberIterator iter = d.MemberBegin(); iter != d.MemberEnd(); ++iter) {
const char * app = iter->name.GetString();
count_service += iter->value["service"].GetUint64();
count_dispatch += iter->value["dispatch"].GetUint64();
}
wchar_t tmp[1024];
swprintf_s(tmp, L"%lld", count_dispatch);
m_dispatch_count.SetWindowTextW(tmp);
swprintf_s(tmp, L"%lld", count_service);
m_service_count.SetWindowTextW(tmp);
}
return 0;
}
示例3: Merge
/**
* Merge one set of options into this one.
* All settings in the input take precedence over anything currently stored.
* @param json_string The serialised JSON string to merge from.
* @return true iff successfully merged.
*/
bool Options::Merge(const char *json_string) {
if (json_string) {
Document d;
d.Parse<0>(json_string);
if (!d.HasParseError() && d.IsObject()) {
//Loop through each family
for (Value::ConstMemberIterator it = d.MemberBegin();
it != d.MemberEnd(); it++)
{
//Do we have a family of options? (e.g. an object)
if (it->value.IsObject()) {
SetFamily(it->name.GetString());
//Loop through each option
for (Value::ConstMemberIterator optit = it->value.MemberBegin();
optit != it->value.MemberEnd(); optit++)
{
const char *optkey = optit->name.GetString();
switch (optit->value.GetType()) {
case kFalseType: case kTrueType:
Set(optkey, optit->value.GetBool());
case kNumberType:
if (optit->value.IsInt()) {
Set(optkey, optit->value.GetInt());
} else if (optit->value.IsNumber()) {
Set(optkey, optit->value.GetDouble());
} else if (optit->value.IsBool()) {
Set(optkey, optit->value.GetBool());
}
break;
case kStringType:
Set(optkey, optit->value.GetString());
break;
case kNullType: //Ignore
break;
default:
Log(LOG_WARNING, "Ignoring unknown option %s of type %d",
optkey, optit->value.GetType());
}
}
} else {
Log(LOG_WARNING, "Ignoring unknown family %s of type %d",
it->name.GetString(), it->value.GetType());
}
}
return true;
}
}
return false;
}
示例4: configStream
std::map<std::string, std::string> ConfigParser::GetConfigMap()
{
std::map<std::string, std::string> configMap;
stringstream err;
FILE* fp = fopen(configPath.c_str(), "rb");
if(!fp){
err << "Could not open file " << configPath << "!";
errors.push_back(err.str());
return configMap;
}
char readBuffer[CONFIGPARSER_BUF_SIZE] = {};
FileReadStream configStream(fp, readBuffer, sizeof(readBuffer));
Document d;
d.ParseStream(configStream);
if(!d.IsObject()){
return configMap;
}
for(Value::MemberIterator it = d.MemberBegin(); it != d.MemberEnd(); ++it){
if ( !it->name.IsString() )
{
LOG_RELEASE("Warning: JSON key value is not a string.");
continue;
}
if(strcmp(it->name.GetString(),"Port") == 0){
configMap[it->name.GetString()] = "";
}
else if(strcmp(it->name.GetString(),"Roster") == 0){
configMap[it->name.GetString()] = "";
}
else{
// Ignore non-string
if ( it->value.IsString() )
{
configMap[it->name.GetString()] = it->value.GetString();
}
}
}
fclose(fp);
return configMap;
}
示例5:
Config::ElementGroupType
getAllElementGroups(const Document& doc, const std::vector<SvgElement>& all_elements_)
{
const auto element_groups_it = doc.FindMember("element_groups");
assert(element_groups_it != doc.MemberEnd());
assert(element_groups_it->value.IsArray());
const auto raw_array_of_groups = element_groups_it->value.GetArray();
Config::ElementGroupType all_element_groups;
all_element_groups.set_empty_key(std::string{""});
for (const auto& raw_single_group: raw_array_of_groups)
{
assert(raw_single_group.IsObject());
const auto& single_group = raw_single_group.GetObject();
//group name
const auto group_name_it = single_group.FindMember("name");
assert(group_name_it != single_group.MemberEnd());
assert(group_name_it->value.IsString());
const auto group_name = std::string {group_name_it->value.GetString(), group_name_it->value.GetStringLength()};
//all the elements that are part of the group
std::vector<std::string> single_group_members;
const auto raw_single_group_members = single_group.FindMember("elements");
assert(raw_single_group_members != single_group.MemberEnd());
assert(raw_single_group_members->value.IsArray());
const auto raw_array_of_group_members = raw_single_group_members->value.GetArray();
for (const auto& raw_single_group_element : raw_array_of_group_members)
{
assert(raw_single_group_element.IsString());
single_group_members.emplace_back(std::string{raw_single_group_element.GetString(),
raw_single_group_element.GetStringLength()});
}
all_element_groups[group_name] = std::move(single_group_members);
}
for (auto& array_name_pair : all_element_groups)
{
auto& element_vector = array_name_pair.second;
std::sort(std::begin(element_vector), std::end(element_vector));
}
// TODO: this line is for debug purposes, should be removed
std::cout << all_elements_;
return all_element_groups;
}
示例6: parseSprite
Sprites parseSprite(const std::string& image, const std::string& json) {
using namespace rapidjson;
Sprites sprites;
// Parse the sprite image.
const util::Image raster(image);
if (!raster) {
Log::Warning(Event::Sprite, "Could not parse sprite image");
return sprites;
}
Document doc;
doc.Parse<0>(json.c_str());
if (doc.HasParseError()) {
Log::Warning(Event::Sprite, std::string{ "Failed to parse JSON: " } + doc.GetParseError() +
" at offset " + std::to_string(doc.GetErrorOffset()));
return sprites;
} else if (!doc.IsObject()) {
Log::Warning(Event::Sprite, "Sprite JSON root must be an object");
return sprites;
} else {
for (Value::ConstMemberIterator itr = doc.MemberBegin(); itr != doc.MemberEnd(); ++itr) {
const std::string name = { itr->name.GetString(), itr->name.GetStringLength() };
const Value& value = itr->value;
if (value.IsObject()) {
const uint16_t x = getUInt16(value, "x", 0);
const uint16_t y = getUInt16(value, "y", 0);
const uint16_t width = getUInt16(value, "width", 0);
const uint16_t height = getUInt16(value, "height", 0);
const double pixelRatio = getDouble(value, "pixelRatio", 1);
const bool sdf = getBoolean(value, "sdf", false);
auto sprite = createSpriteImage(raster, x, y, width, height, pixelRatio, sdf);
if (sprite) {
sprites.emplace(name, sprite);
}
}
}
}
return sprites;
}
示例7: getAllElements
Config::ElementContainerType getAllElements(const Document& doc)
{
// load elements
const auto elements_it = doc.FindMember("elements");
assert(elements_it != doc.MemberEnd());
assert(elements_it->value.IsArray());
std::vector<SvgElement> all_elements;
const auto raw_elements = elements_it->value.GetArray();;
for (SizeType i = 0; i < raw_elements.Size(); ++i)
{
const Value& singleElement = raw_elements[i];
assert(singleElement.IsString());
all_elements.emplace_back(SvgElement{singleElement.GetString()});
}
std::sort(std::begin(all_elements), std::end(all_elements));
return all_elements;
}
示例8: SetTitleInfo
/// <summary>
/// PlayFab Title cannot be created from SDK tests, so you must provide your titleId to run unit tests.
/// (Also, we don't want lots of excess unused titles)
/// </summary>
static void SetTitleInfo(Document &testInputs)
{
// Parse all the inputs
auto end = testInputs.MemberEnd();
auto each = testInputs.FindMember("titleId");
if (each != end) playFabSettings->titleId = each->value.GetString();
string blah;
each = testInputs.FindMember("titleCanUpdateSettings");
if (each != end) blah = each->value.GetString();
TITLE_CAN_UPDATE_SETTINGS = (blah.compare("true") == 0 || blah.compare("True") == 0 || blah.compare("TRUE") == 0);
each = testInputs.FindMember("userName");
if (each != end) userName = each->value.GetString();
each = testInputs.FindMember("userEmail");
if (each != end) userEmail = each->value.GetString();
each = testInputs.FindMember("userPassword");
if (each != end) userPassword = each->value.GetString();
each = testInputs.FindMember("characterName");
if (each != end) characterName = each->value.GetString();
}
示例9: 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();
//.........这里部分代码省略.........
示例10: parseAttributeValue
/* ****************************************************************************
*
* parseAttributeValue -
*/
std::string parseAttributeValue(ConnectionInfo* ciP, ContextAttribute* caP)
{
Document document;
OrionError oe;
document.Parse(ciP->payload);
if (document.HasParseError())
{
LM_W(("Bad Input (JSON parse error)"));
oe.fill(SccBadRequest, "Errors found in incoming JSON buffer");
ciP->httpStatusCode = SccBadRequest;;
return oe.render(ciP, "");
}
if (!document.IsObject())
{
LM_E(("Bad Input (JSON Parse Error)"));
oe.fill(SccBadRequest, "Error parsing incoming JSON buffer");
ciP->httpStatusCode = SccBadRequest;;
return oe.render(ciP, "");
}
if (!document.HasMember("value"))
{
LM_W(("Bad Input (No attribute value specified"));
oe.fill(SccBadRequest, "no attribute value specified");
ciP->httpStatusCode = SccBadRequest;;
return oe.render(ciP, "");
}
for (Value::ConstMemberIterator iter = document.MemberBegin(); iter != document.MemberEnd(); ++iter)
{
std::string name = iter->name.GetString();
std::string type = jsonParseTypeNames[iter->value.GetType()];
if (name != "value")
{
LM_W(("Bad Input (unexpected JSON field - accepting only 'value'"));
oe.fill(SccBadRequest, "unexpected JSON field - accepting only /value/");
ciP->httpStatusCode = SccBadRequest;;
return oe.render(ciP, "");
}
if (type == "String")
{
caP->valueType = orion::ValueTypeString;
caP->stringValue = iter->value.GetString();
}
else if (type == "Number")
{
caP->numberValue = iter->value.GetDouble();
caP->valueType = orion::ValueTypeNumber;
}
else if (type == "True")
{
caP->boolValue = true;
caP->valueType = orion::ValueTypeBoolean;
}
else if (type == "False")
{
caP->boolValue = false;
caP->valueType = orion::ValueTypeBoolean;
}
else if (type == "Array")
{
caP->valueType = orion::ValueTypeVector;
std::string r = parseContextAttributeCompoundValue(iter, caP, NULL);
if (r != "OK")
{
LM_W(("Bad Input (json error in ContextAttributeObject::Vector"));
return "json error in ContextAttributeObject::Vector";
}
}
else if (type == "Object")
{
caP->valueType = orion::ValueTypeObject;
std::string r = parseContextAttributeCompoundValue(iter, caP, NULL);
if (r != "OK")
{
LM_W(("Bad Input (json error in ContextAttributeObject::Object"));
return "json error in ContextAttributeObject::Object";
}
}
}
return "OK";
}
示例11: parseEntity
/* ****************************************************************************
*
* parseEntity -
*
* This function is used to parse two slightly different payloads:
* - POST /v2/entities
* - POST /v2/entities/<eid>
*
* In the latter case, "id" CANNOT be in the payload, while in the former case,
* "id" MUST be in the payload.
*
* In the case of /v2/entities/<eid>, the entityId of 'Entity* eP' is set in
* the service routine postEntity.
*
*/
std::string parseEntity(ConnectionInfo* ciP, Entity* eP, bool eidInURL)
{
Document document;
document.Parse(ciP->payload);
if (document.HasParseError())
{
LM_W(("Bad Input (JSON parse error)"));
eP->errorCode.fill("ParseError", "Errors found in incoming JSON buffer");
ciP->httpStatusCode = SccBadRequest;;
return eP->render(ciP, EntitiesRequest);
}
if (!document.IsObject())
{
LM_E(("Bad Input (JSON Parse Error)"));
eP->errorCode.fill("ParseError", "Error parsing incoming JSON buffer");
ciP->httpStatusCode = SccBadRequest;;
return eP->render(ciP, EntitiesRequest);
}
if (eidInURL == false)
{
if (!document.HasMember("id"))
{
LM_W(("Bad Input (No entity id specified"));
eP->errorCode.fill("ParseError", "no entity id specified");
ciP->httpStatusCode = SccBadRequest;;
return eP->render(ciP, EntitiesRequest);
}
}
for (Value::ConstMemberIterator iter = document.MemberBegin(); iter != document.MemberEnd(); ++iter)
{
std::string name = iter->name.GetString();
std::string type = jsonParseTypeNames[iter->value.GetType()];
if (name == "id")
{
if (eidInURL == false)
{
if (type != "String")
{
LM_W(("Bad Input (invalid JSON type for entity id"));
eP->errorCode.fill("ParseError", "invalid JSON type for entity id");
ciP->httpStatusCode = SccBadRequest;;
return eP->render(ciP, EntitiesRequest);
}
eP->id = iter->value.GetString();
}
else // "id" present in payload for /v2/entities/<eid> - not a valid payload
{
LM_W(("Bad Input ('id' is not a valid attribute"));
eP->errorCode.fill("ParseError", "invalid input, 'id' as attribute");
ciP->httpStatusCode = SccBadRequest;;
return eP->render(ciP, EntitiesRequest);
}
}
else if (name == "type")
{
if (type != "String")
{
LM_W(("Bad Input (invalid JSON type for entity type"));
eP->errorCode.fill("ParseError", "invalid JSON type for entity type");
ciP->httpStatusCode = SccBadRequest;;
return eP->render(ciP, EntitiesRequest);
}
eP->type = iter->value.GetString();
}
else
{
ContextAttribute* caP = new ContextAttribute();
eP->attributeVector.push_back(caP);
std::string r = parseContextAttribute(ciP, iter, caP);
if (r != "OK")
{
LM_W(("Bad Input (parse error in context attribute)"));
eP->errorCode.fill("ParseError", r);
//.........这里部分代码省略.........
示例12: decode
GameState* JsonEncodeDecode::decode(const char *buffer)
{
Document doc;
// Parse and catch errors
if (doc.Parse(buffer).HasParseError())
{
printf("\n----------\nError (offset %u): %s\n----------\n",
(unsigned)doc.GetErrorOffset(),
GetParseError_En(doc.GetParseError()));
return NULL;
}
// Create new GameState
GameState* state = new GameState();
// Iterate through JSON document
for (Value::ConstMemberIterator itr = doc.MemberBegin(); itr != doc.MemberEnd(); ++itr)
{
/*
* GAME OVER STATE
*/
if (strcmp(itr->name.GetString(), "GameOver") == 0)
{
int gameOver = itr->value.GetInt();
state->setGameOver(gameOver);
}
/*
* TIME TO RESTART
*/
if (strcmp(itr->name.GetString(), "SecToRestart") == 0)
{
int secToRestart = itr->value.GetInt();
state->setSecToRestart(secToRestart);
}
/*
* VEHICLES
*/
if (strcmp(itr->name.GetString(), "Vehicles") == 0)
{
// If Vehicles is not an array, something went wrong
if (!itr->value.IsArray())
{
printf("\n----------\nError: Vehicles array is not array\n----------\n");
return NULL;
}
const Value& vehicleArray = itr->value;
for (SizeType i = 0; i < vehicleArray.Size(); i++)
{
if (decodeVehicle(state, vehicleArray[i]) == -1)
{
printf("\n----------\nError decoding vehicles\n----------\n");
return NULL;
}
}
}
/*
* BULLETS
*/
if (strcmp(itr->name.GetString(), "Bullets") == 0)
{
// If Bullets is not an array, something went wrong
if (!itr->value.IsArray())
{
printf("\n----------\nError: Bullets array is not array\n----------\n");
return NULL;
}
const Value& bulletArray = itr->value;
for (SizeType i = 0; i < bulletArray.Size(); i++)
{
if (decodeBullet(state, bulletArray[i]) == -1)
{
printf("\n----------\nError decoding bullets\n----------\n");
return NULL;
}
}
}
/*
* BASES
*/
if (strcmp(itr->name.GetString(), "Bases") == 0)
{
// If Bases is not an array, something went wrong
if (!itr->value.IsArray())
{
printf("\n----------\nError: Bases array is not array\n----------\n");
return NULL;
}
const Value& basesArray = itr->value;
for (SizeType i = 0; i < basesArray.Size(); i++)
{
if (decodeBase(state, basesArray[i]) == -1)
{
//.........这里部分代码省略.........
示例13: NodeBtHandler
//.........这里部分代码省略.........
cout << refreshRateCounter << endl;
} // BT Publisher kısmının sonu
// Sunucu tarafından gönderilen Matlab komutlarına Subscribe olunuyor
else
{
status = serverReqReader->take(serverReqSeq,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ANY_INSTANCE_STATE);
checkStatus(status, "severReqDataReader::read");
for (DDS::ULong j = 0; j < serverReqSeq.length(); j++)
{
if(infoSeq[j].valid_data)
{
cout << "=== [Subscriber] message received :" << endl;
cout << " Received Request Message : "
<< serverReqSeq[j].request << endl;
cout << " Received RequestID : \""
<< serverReqSeq[j].requestID << "\"" << endl;
// Rapidjson yapılandırıcısı yaratılıyor
Document d;
if(d.Parse(serverReqSeq[j].request).HasParseError())
cout << " Parsing Error!" << endl;
StringBuffer nodeIdBuffer;
Writer<StringBuffer> nodeIdWriter(nodeIdBuffer);
d["NodeID"].Accept(nodeIdWriter);
string tempNodeId = nodeIdBuffer.GetString();
// Subscribe olunan mesajın düğüme ait olup olmadığı kontrol ediliyor
if (tempNodeId == "\"SensDug13\"")
{
StringBuffer buffer;
Value::ConstMemberIterator itr = d.FindMember("SetRefreshRate");
// Ref Rate komutunun gelip gelmediği kontrol ediliyor
if(itr != d.MemberEnd())
{
string refreshRateString;
int refreshRateInt;
// Document formatındaki JSON mesajı StrinBuffer'a dönüştürülüyor
Writer<StringBuffer> writer(buffer);
d["SetRefreshRate"].Accept(writer);
refreshRateString = buffer.GetString();
// Gelen mesajda fazladan çift tırnak ile bulunuyor
// Örneğin, ""15""
// Bu yüzden ilk son karakterler kırpılıyor
refreshRateString =
refreshRateString.substr(1, refreshRateString.size()-1);
// Refresh rate değeri stringden integera çevriliyor
refreshRateInt = atoi(refreshRateString.c_str());
refreshRate = refreshRateInt;
timelimit.setMaxDuration(std::chrono::milliseconds
(refreshRate*1000));
}
}
else
cout << "Invalid NodeID!" << endl;
}
}
status = serverReqReader->return_loan(serverReqSeq, infoSeq);
checkStatus(status, "ServerReqDataReader::return_loan");
refreshRateCounter++;
cout << refreshRateCounter << endl;
} // Matlab komutuna Subscribe olma kısmının sonu
// Terminalde akacak olan çıktıları dah gözle görülebilir bir şekilde
// yazdırmak için koyulmuştur
FakeDelay();
}
// Hafıza temizle işlemleri gerçekleştiriliyor
mgrBtPub.deleteWriter();
mgrBtPub.deletePublisher();
mgrBtPub.deleteTopic();
mgrBtPub.deleteParticipant();
mgrReqSub.deleteReader();
mgrReqSub.deleteSubscriber();
mgrReqSub.deleteTopic();
mgrReqSub.deleteParticipant();
return 0;
}
示例14: parseBatchQuery
/* ****************************************************************************
*
* parseBatchQuery -
*/
std::string parseBatchQuery(ConnectionInfo* ciP, BatchQuery* bqrP)
{
Document document;
document.Parse(ciP->payload);
if (document.HasParseError())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "JSON Parse Error");
ec.fill(ERROR_STRING_PARSERROR, "Errors found in incoming JSON buffer");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
if (!document.IsObject())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "JSON Parse Error");
ec.fill("BadRequest", "JSON Parse Error");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
else if (document.ObjectEmpty())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "Empty JSON payload");
ec.fill("BadRequest", "empty payload");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
else if (!document.HasMember("entities") && !document.HasMember("attributes") && !document.HasMember("scopes"))
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "Invalid JSON payload, no relevant fields found");
ec.fill("BadRequest", "Invalid JSON payload, no relevant fields found");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
for (Value::ConstMemberIterator iter = document.MemberBegin(); iter != document.MemberEnd(); ++iter)
{
std::string name = iter->name.GetString();
std::string type = jsonParseTypeNames[iter->value.GetType()];
if (name == "entities")
{
std::string r = parseEntityVector(ciP, iter, &bqrP->entities, false); // param 4: attributes are NOT allowed in payload
if (r != "OK")
{
ErrorCode ec("BadRequest", r);
alarmMgr.badInput(clientIp, r);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
else if (name == "attributes")
{
std::string r = parseAttributeList(ciP, iter, &bqrP->attributeV);
if (r != "OK")
{
ErrorCode ec("BadRequest", r);
alarmMgr.badInput(clientIp, r);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
else if (name == "scopes")
{
std::string r = parseScopeVector(ciP, iter, &bqrP->scopeV);
if (r != "OK")
{
ErrorCode ec("BadRequest", r);
alarmMgr.badInput(clientIp, r);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
else
{
std::string description = std::string("Unrecognizedfield in JSON payload: /") + name + "/";
ErrorCode ec("BadRequest", description);
//.........这里部分代码省略.........
示例15: NodeWifiHandler
//.........这里部分代码省略.........
// isDataReceived değişkeni bir kontrol değişkeni olup, Matlab komut
// bilgisini içeren mesaja Subscribe olunduysa true, olunmadıysa false
// değerini tutar
bool isDataReceived = false;
for (DDS::ULong j = 0; j < serverReqSeq.length(); j++)
{
if(infoSeq[j].valid_data)
{
cout << "=== [Subscriber] message received :" << endl;
cout << " Received Request Message : "
<< serverReqSeq[j].request << endl;
cout << " Received RequestID : \""
<< serverReqSeq[j].requestID << "\"" << endl;
// Rapidjson yapılandırıcısı yaratılıyor
Document d;
if(d.Parse(serverReqSeq[j].request).HasParseError())
cout << " Parsing Error!" << endl;
StringBuffer nodeIdBuffer;
Writer<StringBuffer> nodeIdWriter(nodeIdBuffer);
d["NodeID"].Accept(nodeIdWriter);
string tempNodeId = nodeIdBuffer.GetString();
// Subscribe olunan mesajın düğüme ait olup olmadığı kontrol ediliyor
if (tempNodeId == "\"SensDug13\"")
{
StringBuffer buffer;
// Reset komutunun gelip gelmediği kontrol ediliyor.
Value::ConstMemberIterator itr = d.FindMember("Reset");
if(itr != d.MemberEnd())
{
// Resetin değeri falsedan trueya çevriliyor
Value& s = d["Reset"];
s.SetBool(true);
// Document formatındaki JSON mesajı StrinBuffer'a dönüştürülüyor
Writer<StringBuffer> writer(buffer);
d.Accept(writer);
cout << " Request Message is modified to : "
<< buffer.GetString() << endl;
// Publish edilecek Response mesajı hazırlanıyor
string str = buffer.GetString();
str.append("\n");
serverReq->request = DDS::string_dup(str.c_str());
serverReq->requestID = serverReqSeq[j].requestID;
if(!isDataReceived && status == DDS::RETCODE_OK)
{
// Response mesajı gönderiliyor
ReturnCode_t tempStatus = serverReqWriter->write(
*serverReq, DDS::HANDLE_NIL);
checkStatus(tempStatus, "severReqDataReader::write");
isDataReceived = true;
cout << " Response Request Message is sent : "
<< serverReq->request << endl;
cout << " Response RequestID is sent : \""
<< serverReq->requestID << "\"" << endl;
}