本文整理汇总了C++中xml_node::first_child方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::first_child方法的具体用法?C++ xml_node::first_child怎么用?C++ xml_node::first_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml_node
的用法示例。
在下文中一共展示了xml_node::first_child方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseCFA
void Camera::parseCFA(xml_node &cur) {
if (isTag(cur.name(), "ColorRow")) {
int y = cur.attribute("y").as_int(-1);
if (y < 0 || y >= cfa.size.y) {
ThrowCME("Invalid y coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
}
const char* key = cur.first_child().value();
if ((int)strlen(key) != cfa.size.x) {
ThrowCME("Invalid number of colors in definition for row %d in camera %s %s. Expected %d, found %d.", y, make.c_str(), model.c_str(), cfa.size.x, strlen(key));
}
for (int x = 0; x < cfa.size.x; x++) {
char v = (char)tolower((int)key[x]);
if (v == 'g')
cfa.setColorAt(iPoint2D(x, y), CFA_GREEN);
else if (v == 'r')
cfa.setColorAt(iPoint2D(x, y), CFA_RED);
else if (v == 'b')
cfa.setColorAt(iPoint2D(x, y), CFA_BLUE);
else if (v == 'f')
cfa.setColorAt(iPoint2D(x, y), CFA_FUJI_GREEN);
else if (v == 'c')
cfa.setColorAt(iPoint2D(x, y), CFA_CYAN);
else if (v == 'm')
cfa.setColorAt(iPoint2D(x, y), CFA_MAGENTA);
else if (v == 'y')
cfa.setColorAt(iPoint2D(x, y), CFA_YELLOW);
else
supported = FALSE;
}
}
if (isTag(cur.name(), "Color")) {
int x = cur.attribute("x").as_int(-1);
if (x < 0 || x >= cfa.size.x) {
ThrowCME("Invalid x coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
}
int y = cur.attribute("y").as_int(-1);
if (y < 0 || y >= cfa.size.y) {
ThrowCME("Invalid y coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str());
}
const char* key = cur.first_child().value();
if (isTag(key, "GREEN"))
cfa.setColorAt(iPoint2D(x, y), CFA_GREEN);
else if (isTag(key, "RED"))
cfa.setColorAt(iPoint2D(x, y), CFA_RED);
else if (isTag(key, "BLUE"))
cfa.setColorAt(iPoint2D(x, y), CFA_BLUE);
else if (isTag(key, "FUJIGREEN"))
cfa.setColorAt(iPoint2D(x, y), CFA_FUJI_GREEN);
else if (isTag(key, "CYAN"))
cfa.setColorAt(iPoint2D(x, y), CFA_CYAN);
else if (isTag(key, "MAGENTA"))
cfa.setColorAt(iPoint2D(x, y), CFA_MAGENTA);
else if (isTag(key, "YELLOW"))
cfa.setColorAt(iPoint2D(x, y), CFA_YELLOW);
}
}
示例2: parseAlias
void Camera::parseAlias( xml_node &cur )
{
if (isTag(cur.name(), "Alias")) {
aliases.push_back(string(cur.first_child().value()));
pugi::xml_attribute key = cur.attribute("id");
if (key)
canonical_aliases.push_back(string(key.as_string()));
else
canonical_aliases.push_back(string(cur.first_child().value()));
}
}
示例3: handler
ProcessResult MsgTypeIqProcessHandler::handler(SessionPtr sessionPtr, const xml_node& node){
ProcessResult result;
ostringstream os;
sessionPtr->delAllSupportType();
for(xml_node msgType = node.first_child(); msgType; msgType = msgType.next_sibling()){
if(strcmp(msgType.name(), "msgType") != 0){
continue;
}
string msgTypeStr = msgType.child_value();
boost::trim(msgTypeStr);
if(msgTypeStr == "chat"){
sessionPtr->addSupportType(MessageType::CHAT);
} else if (msgTypeStr == "feed"){
sessionPtr->addSupportType(MessageType::FEED);
} else if (msgTypeStr == "notify"){
sessionPtr->addSupportType(MessageType::NOTIFY);
}
}
string id = node.attribute("id").value();
string from = node.attribute("from").value();
result.setCode(ProcessResult::HAS_RESPONSE);
os << "<iq id='" << id << "' to='" << from << "' type='result'>"
<< "<success/></iq>";
result.setMsg(os.str());
return result;
}
示例4: loadMod
void ItemManager::loadMod(xml_node& root, Modifier *mod)
{
for(auto item = root.first_child(); item; item = item.next_sibling())
{
//WriteLog("item name %s, cv %s", item.name(), item.child_value());
if(!strcmp(item.name(), "pname"))
mod->name = (ParamName)atoi(item.child_value());
if(!strcmp(item.name(), "value"))
mod->value = atoi(item.child_value());
}
}
示例5: parse_gdimm_setting_node
void gdipp_setting::parse_gdimm_setting_node(const xml_node &setting_node, setting_map &setting_store)
{
const string_t name = setting_node.name();
if (name == L"freetype" || name == L"gamma" || name == L"render_mode" || name == L"shadow")
{
// these settings have nested items
for (xml_node::iterator iter = setting_node.begin(); iter != setting_node.end(); iter++)
setting_store[name + L"/" + iter->name()] = iter->first_child().value();
}
else
setting_store[name] = setting_node.first_child().value();
}
示例6: processNode
void Editor_Html2Usfm::processNoteCitation (xml_node node)
{
// Remove the note citation from the text.
// It means that this:
// <a href="#note1" id="citation1" class="superscript">x</a>
// becomes this:
// <a href="#note1" id="citation1" class="superscript" />
xml_node child = node.first_child ();
node.remove_child (child);
// Get more information about the footnote to retrieve.
string href = node.attribute ("href").value ();
string id = href.substr (1);
// Sample footnote body.
// <p class="x"><a href="#citation1" id="note1">x</a><span> </span><span>+ 2 Joh. 1.1</span></p>
// Retrieve the <a> element from it.
// At first this was done through an XPath expression:
// http://www.grinninglizard.com/tinyxml2docs/index.html
// But XPath crashes on Android with libxml2.
// Therefore now it iterates of all the nodes to find the required <a> element.
// (After moving to pugixml, the XPath expression could have been used again, but this was not done.)
xml_node aElement = get_note_pointer (document.first_child (), id);
if (aElement) {
// It now has the 'a' element: Get its 'p' parent, and then remove that 'a' element.
// So we remain with:
// <p class="x"><span> </span><span>+ 2 Joh. 1.1</span></p>
xml_node pElement = aElement.parent ();
pElement.remove_child (aElement);
// Preserve active character styles in the main text, and reset them for the note.
vector <string> preservedCharacterStyles = characterStyles;
characterStyles.clear();
// Process this 'p' element.
processingNote = true;
processNode (pElement);
processingNote = false;
// Restore the active character styles for the main text.
characterStyles = preservedCharacterStyles;
// Remove this element so it can't be processed again.
xml_node div_notes = pElement.parent ();
div_notes.remove_child (pElement);
} else {
Database_Logs::log ("Discarding note with id " + id + " and href " + href);
}
}
示例7: loadMods
void ItemManager::loadMods(xml_node &root, std::vector<Modifier>& mods)
{
for(auto item = root.first_child(); item; item = item.next_sibling())
{
//WriteLog("item name %s, cv %s", item.name(), item.child_value());
if(!strcmp(item.name(), "mod"))
{
Modifier mod;
loadMod(item, &mod);
mods.push_back(mod);
}
}
}
示例8: parseID
void Camera::parseID( xml_node &cur )
{
if (isTag(cur.name(), "ID")) {
pugi::xml_attribute id_make = cur.attribute("make");
if (id_make) {
canonical_make = string(id_make.as_string());
} else
ThrowCME("CameraMetadata: Could not find make for ID for %s %s camera.", make.c_str(), model.c_str());
pugi::xml_attribute id_model = cur.attribute("model");
if (id_model) {
canonical_model = string(id_model.as_string());
} else
ThrowCME("CameraMetadata: Could not find model for ID for %s %s camera.", make.c_str(), model.c_str());
canonical_id = string(cur.first_child().value());
}
}
示例9: parseCameraChild
void Camera::parseCameraChild(xml_node &cur) {
if (isTag(cur.name(), "CFA")) {
if (2 != cur.attribute("width").as_int(0) || 2 != cur.attribute("height").as_int(0)) {
supported = FALSE;
} else {
cfa.setSize(iPoint2D(2,2));
xml_node c = cur.child("Color");
while (c != NULL) {
parseCFA(c);
c = c.next_sibling("Color");
}
}
return;
}
if (isTag(cur.name(), "CFA2")) {
cfa.setSize(iPoint2D(cur.attribute("width").as_int(0),cur.attribute("height").as_int(0)));
xml_node c = cur.child("Color");
while (c != NULL) {
parseCFA(c);
c = c.next_sibling("Color");
}
c = cur.child("ColorRow");
while (c != NULL) {
parseCFA(c);
c = c.next_sibling("ColorRow");
}
return;
}
if (isTag(cur.name(), "Crop")) {
cropPos.x = cur.attribute("x").as_int(0);
cropPos.y = cur.attribute("y").as_int(0);
if (cropPos.x < 0)
ThrowCME("Negative X axis crop specified in camera %s %s", make.c_str(), model.c_str());
if (cropPos.y < 0)
ThrowCME("Negative Y axis crop specified in camera %s %s", make.c_str(), model.c_str());
cropSize.x = cur.attribute("width").as_int(0);
cropSize.y = cur.attribute("height").as_int(0);
return;
}
if (isTag(cur.name(), "Sensor")) {
parseSensorInfo(cur);
return;
}
if (isTag(cur.name(), "BlackAreas")) {
xml_node c = cur.first_child();
while (c != NULL) {
parseBlackAreas(c);
c = c.next_sibling();
}
return;
}
if (isTag(cur.name(), "Aliases")) {
xml_node c = cur.child("Alias");
while (c != NULL) {
parseAlias(c);
c = c.next_sibling();
}
return;
}
if (isTag(cur.name(), "Hints")) {
xml_node c = cur.child("Hint");
while (c != NULL) {
parseHint(c);
c = c.next_sibling();
}
return;
}
if (isTag(cur.name(), "ID")) {
parseID(cur);
return;
}
}
示例10: loadValue
Value loadValue(xml_node node)
{
const char* name = node.name();
Value val;
if(strcmp(name, "dict") == 0)
{
ValueMap map;
char* key;
bool isKey = true;
for(xml_node child = node.first_child(); child; child = child.next_sibling())
{
if(isKey)
{
key = const_cast<char*>(child.first_child().value());//remove const while reading value, easier that way
}
else
{
Value result = loadValue(child);
if(!result.isNull())
{
map[key] = result;
}
}
isKey = !isKey;
}
val = map;
}
else if(strcmp(name, "intKeydict") == 0)
{
ValueMapIntKey map;
char* key;
bool isKey = true;
for(xml_node child = node.first_child(); child; child = child.next_sibling())
{
if(isKey)
{
key = const_cast<char*>(child.first_child().value());//remove const while reading value, easier that way
}
else
{
Value result = loadValue(child);
if(!result.isNull())
{
map[std::atoi(key)] = result;
}
}
isKey = !isKey;
}
val = map;
}
else if(strcmp(name, "intKeydict") == 0)
{
ValueMapIntKey map;
char* key;
bool isKey = true;
for(xml_node child = node.first_child(); child; child = child.next_sibling())
{
if(isKey)
{
key = const_cast<char*>(child.first_child().value());//remove const while reading value, easier that way
}
else
{
Value result = loadValue(child);
if(result.getType() != Value::Type::NONE)
{
map[std::atoi(key)] = result;
}
}
isKey = !isKey;
}
val = map;
}
else if(strcmp(name, "array") == 0)
{
ValueVector vector;
for(xml_node child = node.first_child(); child; child = child.next_sibling())
{
Value result = loadValue(child);
if(!result.isNull())
{
vector.push_back(result);
}
}
val = vector;
}
else if(strcmp(name, "string") == 0)
{
val = Value(node.first_child().value());
}
else if(strcmp(name, "integer") == 0)
{
val = Value(atoi(node.first_child().value()));
}
else if(strcmp(name, "real") == 0)
{
val = Value(atof(node.first_child().value()));
}
else if(strcmp(name, "true") == 0)
{
//.........这里部分代码省略.........
示例11: parseMeasure
bool MxmlMeasure::parseMeasure(xml_node mel) {
bool output = true;
vector<vector<int> > staffVoiceCounts;
setStartTimeOfMeasure();
HumNum starttime = getStartTime();
HumNum st = starttime;
HumNum maxst = starttime;
xml_node nextel;
for (auto el = mel.first_child(); el; el = el.next_sibling()) {
MxmlEvent* event = new MxmlEvent(this);
m_events.push_back(event);
nextel = el.next_sibling();
output &= event->parseEvent(el, nextel, starttime);
starttime += event->getDuration();
if (starttime > maxst) {
maxst = starttime;
}
}
setDuration(maxst - st);
// Should no longer be needed:
// calculateDuration();
bool needdummy = false;
MxmlMeasure* pmeasure = getPreviousMeasure();
if (getTimeSigDur() <= 0) {
if (pmeasure) {
setTimeSigDur(pmeasure->getTimeSigDur());
}
}
if (getDuration() == 0) {
if (pmeasure) {
setDuration(pmeasure->getTimeSigDur());
} else {
setTimeSigDur(getTimeSigDur());
}
needdummy = true;
}
// Maybe check for overfull measures around here
if (needdummy || getEventCount() == 0) {
// if the duration of the measure is zero, then set the duration
// of the measure to the duration of the time signature
// This is needed for certain cases of multi-measure rests, where no
// full-measure rest is given in the measure (Sibelius does this).
setDuration(getTimeSigDur());
addDummyRest();
}
// Neeed to check for empty voice/layers occuring lower in the
// voice index list than layers which contain notes. For example
// if voice/layer 2 contains notes, but voice/layer 1 does not, then
// a dummy full-measure rest should fill voice/layer 1. The voice
// layer 1 should be filled with the duration of the measure according
// to the other voice/layers in the measure. This is done later
// after a voice analysis has been done in
// musicxml2hum_interface::insertMeasure(), specifically:
// musicxml2hum_interface::checkForDummyRests().
sortEvents();
return output;
}