本文整理汇总了C++中XMLAttributes::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLAttributes::getValue方法的具体用法?C++ XMLAttributes::getValue怎么用?C++ XMLAttributes::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLAttributes
的用法示例。
在下文中一共展示了XMLAttributes::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onStyleGroup
void SchemeConfigParser::onStyleGroup(const XMLAttributes& att, const StylePtr& pClass)
{
PNASSERT(m_pCurrent != NULL);
LPCTSTR name = att.getValue(_T("name"));
if(name)
{
m_pCurrent->BeginStyleGroup(name, att.getValue(_T("description")), (pClass.get() ? pClass->Style->name.c_str() : NULL) );
}
}
示例2: startElement
void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
{
string Name(name);
Element *temp_element;
working_string.erase();
if (!first_element_read) {
document = new Element(Name);
current_element = document;
first_element_read = true;
} else {
temp_element = new Element(Name);
temp_element->SetParent(current_element);
current_element->AddChildElement(temp_element);
current_element = temp_element;
}
if (current_element == 0L) {
std::stringstream error;
error << "In file " << getPath() << ": line " << getLine() << endl
<< "No current element read (running out of memory?)" << endl;
throw std::runtime_error(error.str());
}
current_element->SetLineNumber(getLine());
current_element->SetFileName(getPath());
for (int i=0; i<atts.size();i++) {
current_element->AddAttribute(atts.getName(i), atts.getValue(i));
}
}
示例3: startElement
void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
{
string Name(name);
Element *temp_element;
working_string.erase();
if (!first_element_read) {
document = new Element(Name);
current_element = document;
first_element_read = true;
} else {
temp_element = new Element(Name);
temp_element->SetParent(current_element);
current_element->AddChildElement(temp_element);
current_element = temp_element;
}
if (current_element == 0L) {
cerr << "No current element read (no top-level element in XML file?)" << endl;
exit (-1);
}
for (int i=0; i<atts.size();i++) {
current_element->AddAttribute(atts.getName(i), atts.getValue(i));
}
}
示例4: XMLAttributes
END_TEST
START_TEST (test_uncertml_attributes)
{
fail_unless ( node->getNumAttributes() == 0 );
XMLAttributes * attr = new XMLAttributes();
attr->add("definition", "http://");
int i = node->setAttributes(*(attr));
fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
fail_unless ( node->getNumAttributes() == 1 );
const XMLAttributes retrieved = node->getAttributes();
fail_unless ( retrieved.isEmpty() == false );
fail_unless ( retrieved.getLength() == 1 );
fail_unless ( retrieved.getName(0) == "definition" );
fail_unless ( retrieved.getValue(0) == "http://" );
i = node->unsetAttributes();
fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
fail_unless ( node->getNumAttributes() == 0 );
fail_unless ( node->getAttributes().isEmpty() == true );
}
示例5: startElement
void MagicFolderCache::startElement(XML_CSTR name, const XMLAttributes& atts)
{
if( IN_STATE( PS_FOLDER ) )
{
if( MATCH("MagicFolder") )
{
_depth++;
// Push this folder path onto the path stack...
_pathStack = newStringStackItem(_pathStack, atts.getValue(_T("name")));
// Store a folder object which will hold configuration etc.
_current = new Folder(_pathStack->val.c_str(), _T(""));
_map->insert(MagicFolderCache::FolderMap::value_type(_pathStack->val, _current));
}
else if( MATCH("File") )
{
STATE(PS_FILE);
processFile(atts);
}
else
{
processUserData(name, atts);
}
}
else if( IN_STATE( PS_FILE ) || IN_STATE( PS_USERDATA ) )
{
processUserData(name, atts);
}
}
示例6: populateDOMAttributes
static void
populateDOMAttributes(const XMLAttributes& src, XERCES_CPP_NAMESPACE::DOMElement* dest)
{
for (size_t i = 0; i < src.getCount(); ++i)
{
dest->setAttribute(XercesHelper::transcode(src.getName(i)).c_str(),
XercesHelper::transcode(src.getValue(i)).c_str());
}
}
示例7: processSchemeElement
void UserSettingsParser::processSchemeElement(SchemeLoaderState* pState, LPCTSTR name, const XMLAttributes& atts)
{
if(pState->m_State == US_STYLE_OVERRIDES)
{
if(_tcscmp(name, _T("style")) == 0)
{
StyleDetails* pStyle = new StyleDetails;
SchemeParser::parseStyle(pState, atts, pStyle);
if(!m_loadingPreset)
{
// Hand off the style to the master style
StylePtr p( new FullStyleDetails(pStyle->Key) );
p->CustomStyle = pStyle;
m_pCurScheme->PreLoadCustomisedStyle( p );
}
else
{
// Apply customisation to existing style...
StylePtr p = m_pCurScheme->GetStyle(pStyle->Key);
if(p != NULL)
{
p->CustomStyle = pStyle;
}
}
}
}
else if (pState->m_State == US_KEYWORD_OVERRIDES)
{
if(_tcscmp(name, _T("keywords")) == 0)
{
LPCTSTR key = atts.getValue(_T("key"));
m_idval = _ttoi(key);
pState->m_CDATA = "";
pState->m_State = US_KEYWORDS;
}
}
else if(pState->m_State == US_SCHEME)
{
if(_tcscmp(name, _T("override-keywords")) == 0)
{
pState->m_State = US_KEYWORD_OVERRIDES;
}
else if(_tcscmp(name, _T("override-styles")) == 0)
{
pState->m_State = US_STYLE_OVERRIDES;
}
else if(_tcscmp(name, _T("colours")) == 0)
{
m_pCurScheme->CustomColours.SetFromXml(atts);
}
}
}
示例8:
LIBSBML_CPP_NAMESPACE_USE
/** @endcond */
CK_CPPSTART
START_TEST (test_XMLAttributes_add_get)
{
XMLAttributes attrs;
fail_unless( attrs.getLength() == 0 );
fail_unless( attrs.getNumAttributes() == 0 );
fail_unless( attrs.isEmpty() );
attrs.add("xmlns", "http://foo.org/");
fail_unless( attrs.getLength() == 1 );
fail_unless( attrs.getNumAttributes() == 1 );
fail_unless( attrs.isEmpty() == false );
attrs.add("foo", "bar");
fail_unless( attrs.getLength() == 2 );
fail_unless( attrs.getNumAttributes() == 2 );
fail_unless( attrs.isEmpty() == false );
fail_unless( attrs.getIndex("xmlns") == 0 );
fail_unless( attrs.getIndex("foo" ) == 1 );
fail_unless( attrs.getIndex("bar" ) == -1 );
fail_unless( attrs.getValue("xmlns") == "http://foo.org/" );
fail_unless( attrs.getValue("foo" ) == "bar" );
fail_unless( attrs.getValue("bar" ) == "" );
fail_unless( attrs.getName(0) == "xmlns" );
fail_unless( attrs.getName(1) == "foo" );
fail_unless( attrs.getName(2) == "" );
}
示例9: startElement
void plotXMLVisitor::startElement (const char * name, const XMLAttributes &atts)
{
current_element = name;
for (int i=0; i<atts.size();i++) {
if (string(atts.getName(i)) == string("axis")) {
if (string(atts.getValue(i)) == string("x")) axis = eX;
else if (string(atts.getValue(i)) == string("y2")) axis = eY2;
else axis = eY;
} else {
cerr << "Unknown attribute " << atts.getName(i) << " encountered." << endl;
exit (-1);
}
if (i == 1) {
cerr << "Too many attributes. Offending attribute (item:" << i << ") is " << atts.getName(i) << endl;
exit (-1);
}
}
if (!first_element_read) {
if (current_element != string("plotset")) {
cerr << endl << " This is not a valid plotset description (" << current_element << ")" << endl;
exit (-1);
} else {
first_element_read = true;
}
}
if (current_element == "page") {
vPages.push_back(Page());
inPage = true;
} else if (current_element == "plot") {
if (!inPage) {
vPlots.push_back(Plots());
} else {
vPages.back().vPlots.push_back(Plots());
}
}
}
示例10: if
void
TerrainData_xmlHandler::startElement(const String& element, const XMLAttributes& attrs)
{
if (element == "Terrain")
{
mData->mName = attrs.getValueAs<String>("name", Ogre::StringUtil::BLANK);
mData->mXSize = attrs.getValueAs<uint>("xsize");
mData->mZSize = attrs.getValueAs<uint>("zsize");
mData->mTileSize = attrs.getValueAs<uint>("tileSize");
}
else if (element == "scale")
{
mData->mScale = Ogre::Vector3(attrs.getValueAs<Real>("x"),
attrs.getValueAs<Real>("y"),
attrs.getValueAs<Real>("z"));
if (mData->mScale.x <= 0 || mData->mScale.y <= 0 || mData->mScale.z <= 0)
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Invalidate scale definition in terrain file",
"TerrainData_xmlHandler::startElement");
}
mData->mPosition = Ogre::Vector3(- mData->mScale.x * mData->mXSize / 2,
0,
- mData->mScale.z * mData->mZSize / 2);
}
else if (element == "size")
{
mData->mScale = Ogre::Vector3(attrs.getValueAs<Real>("x") / mData->mXSize,
attrs.getValueAs<Real>("y"),
attrs.getValueAs<Real>("z") / mData->mZSize);
if (mData->mScale.x <= 0 || mData->mScale.y <= 0 || mData->mScale.z <= 0)
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Invalidate size definition in terrain file",
"TerrainData_xmlHandler::startElement");
}
mData->mPosition = Ogre::Vector3(- mData->mScale.x * mData->mXSize / 2,
0,
- mData->mScale.z * mData->mZSize / 2);
}
else if (element == "position")
{
mData->mPosition = Ogre::Vector3(attrs.getValueAs<Real>("x"),
attrs.getValueAs<Real>("y"),
attrs.getValueAs<Real>("z"));
}
else if (element == "centre" || element == "center")
{
mData->mPosition = Ogre::Vector3(attrs.getValueAs<Real>("x") - mData->mScale.x * mData->mXSize / 2,
attrs.getValueAs<Real>("y"),
attrs.getValueAs<Real>("z") - mData->mScale.z * mData->mZSize / 2);
}
else if (element == "heightmap")
{
const String& type = attrs.getValueAs<String>("type", "standard");
const String& filename = attrs.getValue("filename");
if (type != "image" && type != "standard" && type != "raw")
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Invalidate height data type",
"TerrainData_xmlHandler::startElement");
}
mData->mHeightmapType = type;
mData->mHeightmapFilename = filename;
if (mData->mHeightmapFilename.empty())
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Invalidate height data filename",
"TerrainData_xmlHandler::startElement");
}
}
else if (element == "gridInfo")
{
const String& type = attrs.getValueAs<String>("type", "standard");
const String& filename = attrs.getValue("filename");
if (type != "standard")
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Invalidate height info type",
"TerrainData_xmlHandler::startElement");
}
mData->mGridInfoFilename = filename;
if (mData->mGridInfoFilename.empty())
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Invalidate grid info filename",
"TerrainData_xmlHandler::startElement");
}
}
else if (element == "lightmap")
{
const String& type = attrs.getValueAs<String>("type", "standard");
//.........这里部分代码省略.........
示例11: processScheme
void UserSettingsParser::processScheme(SchemeLoaderState* pState, const XMLAttributes& atts)
{
LPCTSTR pName = atts.getValue(_T("name"));
if(pName && ((int)_tcslen(pName) > 0))
{
if(!m_loadingPreset)
{
CT2CA schemeName(pName);
m_pCurScheme = new SchemeDetails(schemeName);
}
else
{
CT2CA schemeName(pName);
SchemeDetailsMap::iterator iScheme = pState->m_SchemeDetails.find(std::string(schemeName));
if(iScheme != pState->m_SchemeDetails.end())
{
m_pCurScheme = (*iScheme).second;
}
else
{
m_pCurScheme = NULL;
}
}
if(m_pCurScheme == NULL)
return;
//pScheme = new CustomisedScheme;
m_SchemeName = pName;
pState->m_State = US_SCHEME;
LPCTSTR temp = atts.getValue(_T("ovtabs"));
if(temp != NULL && _tcslen(temp) > 0)
{
m_pCurScheme->CustomFlagFlags |= schOverrideTabs;
if(SZTRUE(temp))
// Signal that we definitely want to override the tab use.
m_pCurScheme->CustomFlags |= schOverrideTabs;
temp = atts.getValue(_T("usetabs"));
if(temp != NULL && _tcslen(temp) > 0)
{
m_pCurScheme->CustomFlagFlags |= schUseTabs;
if(SZTRUE(temp))
m_pCurScheme->CustomFlags |= schUseTabs;
}
}
temp = atts.getValue(_T("tabwidth"));
if(temp != NULL && _tcslen(temp) > 0)
{
m_pCurScheme->CustomFlagFlags |= schOverrideTabSize;
m_pCurScheme->CustomFlags |= schOverrideTabSize;
m_pCurScheme->CustomTabWidth = _ttoi(temp);
}
}
#ifdef _DEBUG
else
{
LOG(_T("UserSettingsParser::processScheme(): Scheme section without name attribute.\n"));
}
#endif
}
示例12: startElement
void StructureVisitor::startElement (const char * name, const XMLAttributes &atts)
{
int i;
if (_level == 0)
{
if (string(name) != (string)"structures-file")
{
string message = "Root element name is ";
message += name;
message += "; expected structures-file";
throw xh_io_exception(message, "XML Reader");
}
push_state(NULL, "top");
return;
}
if (_level == 1)
{
if (string(name) == (string)"coordinates")
{
const char *type = atts.getValue("type");
const char *value = atts.getValue("value");
m_pSA->m_proj.SetTextDescription(type, value);
g_Conv.Setup(m_pSA->m_proj.GetUnits(), DRECT(0,1,1,0));
}
else if (string(name) == (string)"structures")
{
push_state(NULL, "structures");
}
else
{
// Unknown element: ignore
push_state(NULL, "dummy");
}
return;
}
const char *attval;
if (_level == 2)
{
vtStructure *pStruct = NULL;
if (string(name) == (string)"structure")
{
// Get the name.
attval = atts.getValue("type");
if (attval != NULL)
{
if (string(attval) == (string)"building")
{
vtBuilding *bld = m_pSA->NewBuilding();
pStruct = bld;
}
if (string(attval) == (string)"linear")
{
vtFence *fen = m_pSA->NewFence();
pStruct = fen;
}
if (string(attval) == (string)"instance")
{
vtStructInstance *inst = m_pSA->NewInstance();
pStruct = inst;
}
}
push_state(pStruct, "structure");
}
else
{
// Unknown field, ignore.
pStruct = NULL;
push_state(pStruct, "dummy");
}
return;
}
State &st = state();
vtStructure *pStruct = st.item;
if (!pStruct)
return;
vtFence *fen = pStruct->GetFence();
vtBuilding *bld = pStruct->GetBuilding();
vtStructInstance *inst = pStruct->GetInstance();
if (_level == 3 && bld != NULL)
{
if (string(name) == (string)"height")
{
attval = atts.getValue("stories");
if (attval)
{
// height in stories ("floors")
int stories = atoi(attval);
if (bld)
bld->SetStories(stories);
}
}
if (string(name) == (string)"walls")
{
attval = atts.getValue("color");
//.........这里部分代码省略.........
示例13: if
XMLNode *
RDFAnnotationParser::createCVTerms(const SBase * object)
{
if (object == NULL) return NULL;
/* create the basic triples */
XMLTriple li_triple = XMLTriple("li",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdf");
XMLTriple bag_triple = XMLTriple("Bag",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdf");
/* attributes */
XMLAttributes blank_att = XMLAttributes();
/* tokens */
XMLToken bag_token = XMLToken(bag_triple, blank_att);
std::string prefix;
std::string name;
std::string uri;
XMLAttributes *resources;
XMLNode *description = createRDFDescription(object);
/* loop through the cv terms and add */
/* want to add these in blocks of same qualifier */
if (object->getCVTerms())
{
for (unsigned int n = 0; n < object->getCVTerms()->getSize(); n++)
{
CVTerm* current = static_cast <CVTerm *> (object->getCVTerms()->get(n));
if (current == NULL) continue;
if (current->getQualifierType() == MODEL_QUALIFIER)
{
prefix = "bqmodel";
uri = "http://biomodels.net/model-qualifiers/";
const char* term = ModelQualifierType_toString(
current->getModelQualifierType());
if (term == NULL) return NULL;
name = term;
}
else if (current
->getQualifierType() == BIOLOGICAL_QUALIFIER)
{
prefix = "bqbiol";
uri = "http://biomodels.net/biological-qualifiers/";
const char* term = BiolQualifierType_toString(
current->getBiologicalQualifierType());
if (term == NULL) return NULL;
name = term;
}
else
{
continue;
}
resources = current->getResources();
XMLNode bag(bag_token);
for (int r = 0; r < resources->getLength(); r++)
{
XMLAttributes att;
att.add(resources->getName(r), resources->getValue(r));
XMLToken li_token(li_triple, att);
li_token.setEnd();
XMLNode li(li_token);
bag.addChild(li);
}
XMLTriple type_triple(name, uri, prefix);
XMLToken type_token(type_triple, blank_att);
XMLNode type(type_token);
type.addChild(bag);
description->addChild(type);
}
}
return description;
}
示例14: startElement
void UtilOSMVisitor::startElement(const char *name, const XMLAttributes &atts)
{
const char *val;
if (m_state == 0)
{
if (!strcmp(name, "node"))
{
DPoint2 p;
val = atts.getValue("id");
if (val)
m_id = atoi(val);
else
m_id = -1; // Shouldn't happen.
val = atts.getValue("lon");
if (val)
p.x = atof(val);
val = atts.getValue("lat");
if (val)
p.y = atof(val);
OSMNode node;
node.p = p;
m_nodes[m_id] = node;
m_state = PS_NODE;
m_pole = NULL;
}
else if (!strcmp(name, "way"))
{
m_refs.clear();
m_state = PS_WAY;
val = atts.getValue("id");
if (val)
m_id = atoi(val);
else
m_id = -1; // Shouldn't happen.
// Defaults
m_line = NULL;
}
}
else if (m_state == PS_NODE && !strcmp(name, "tag"))
{
vtString key, value;
val = atts.getValue("k");
if (val)
key = val;
val = atts.getValue("v");
if (val)
value = val;
if (key == "power" && value == "tower")
StartPowerPole();
// Node key/value
else if (key == "highway")
{
if (value == "traffic_signals")
{
m_nodes[m_nodes.size()-1].signal_lights = true;
}
}
else if (m_pole)
{
// Add all node tags for power towers
m_pole->AddTag(key, value);
}
}
else if (m_state == PS_WAY)
{
if (!strcmp(name, "nd"))
{
val = atts.getValue("ref");
if (val)
{
int ref = atoi(val);
m_refs.push_back(ref);
}
}
else if (!strcmp(name, "tag"))
{
vtString key, value;
val = atts.getValue("k");
if (val)
key = val;
val = atts.getValue("v");
if (val)
value = val;
if (m_line)
m_line->AddTag(key, value);
//.........这里部分代码省略.........
示例15: startElement
void UtilityVisitor::startElement(const char *name, const XMLAttributes &atts)
{
const char *attval;
// clear data at the start of each element
m_data = "";
if (m_state == 0)
{
if (!strcmp(name, "UtilityCollection"))
{
m_state = 1;
}
else
{
string message = "Root element name is ";
message += name;
message += "; expected UtilityCollection";
throw xh_io_exception(message, "XML Reader");
}
return;
}
if (m_state == 1)
{
if (!strcmp(name, "OverheadLine"))
{
m_pRoute = new vtRoute(GetCurrentTerrain()); // Create new route (should this be in vtUtilityMap ??)
attval = atts.getValue("name");
if (attval)
m_pRoute->SetName(attval); // TODO Set Name of the overhead line
GetCurrentTerrain()->AddRoute(m_pRoute);
m_state = 2;
}
return;
}
if (m_state == 2) // Conductor
{
if (!strcmp(name, "Conductor"))
{
attval = atts.getValue("width");
if (attval)
m_pRoute->SetThickness(atof(attval));
attval = atts.getValue("color");
if (attval)
m_pRoute->SetColor(ParseHexColor(attval));
m_state = 3;
}
return;
}
if (m_state == 3) // Pylon
{
if (!strcmp(name, "Pylon"))
{
attval = atts.getValue("name");
if (attval)
SetName(attval);
attval = atts.getValue("reference");
if (attval)
SetReference(attval);
attval = atts.getValue("rotation");
if (attval)
SetRotation(atof(attval));
m_state = 4; // now read in the coordinate ...
}
else
m_state = 1; // then it is a new overhead line
return;
}
}