Patch to property tree to allow repeating tag names. The property manager

simply assigns ordinality as it finds multiple instances.
This commit is contained in:
curt
2001-03-18 21:22:28 +00:00
parent 6cbf4306e7
commit 7db44c113c
2 changed files with 19 additions and 3 deletions

View File

@@ -51,6 +51,9 @@ void SGMagVar::update( double lon, double lat, double alt_m, double jd ) {
double sgGetMagVar( double lon, double lat, double alt_m, double jd ) {
// cout << "lat = " << lat << " lon = " << lon << " elev = " << alt_m
// << " JD = " << jd << endl;
double field[6];
return calc_magvar( lat, lon, alt_m / 1000.0, (long)jd, field );
}

View File

@@ -20,6 +20,7 @@
#endif
#include STL_STRING
#include <vector>
#include <map>
#if !defined(FG_HAVE_NATIVE_SGI_COMPILERS)
FG_USING_STD(istream);
@@ -29,6 +30,7 @@ FG_USING_STD(ofstream);
#endif
FG_USING_STD(string);
FG_USING_STD(vector);
FG_USING_STD(map);
@@ -61,6 +63,7 @@ private:
: node(_node), type(_type) {}
SGPropertyNode * node;
string type;
map<string,int> counters;
};
State &state () { return _state_stack[_state_stack.size() - 1]; }
@@ -104,6 +107,8 @@ PropsVisitor::endXML ()
void
PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
{
State &st = state();
if (_level == 0) {
push_state(_root, "");
}
@@ -111,9 +116,14 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
else {
const char * att_n = atts.getValue("n");
int index = 0;
if (att_n != 0)
if (att_n != 0) {
index = atoi(att_n);
push_state(state().node->getChild(name, index, true),
st.counters[name] = max(st.counters[name], index+1);
} else {
index = st.counters[name];
st.counters[name]++;
}
push_state(st.node->getChild(name, index, true),
atts.getValue("type"));
}
}
@@ -232,6 +242,9 @@ getTypeName (SGValue::Type type)
case SGValue::STRING:
return "string";
}
// keep the compiler from squawking
return "unknown";
}
@@ -241,7 +254,7 @@ getTypeName (SGValue::Type type)
static void
writeData (ostream &output, const string &data)
{
for (int i = 0; i < data.size(); i++) {
for (int i = 0; i < (int)data.size(); i++) {
switch (data[i]) {
case '&':
output << "&amp;";