Hi
I have below classes
Code:
class moClassValueContainer {
public:
moClassValueContainer();
moClassValueContainer(string,int);
string name;
int maxNodeCount;
vector<string> headerFields;
};
typedef enum {SINGLE,LIST} valueType; // this is C style
class Container {
public:
Container (xml_node n);
valueType getType() { return type; }
vector< vector<string> > getListNames();
vector< vector<string> > getListValues();
string getListElement(string n);
string getName();
string getValue();
int getElementCount();
private:
valueType type;
xml_node node;
int count; // for list only, otherwise count = 0
int itemNo;
string name;
string moClass;
vector< vector<string> > listNames;
vector< vector<string> > listValues;
void analyseList();
bool listAnalyzed;
};
Container::Container(xml_node n) {
node = n;
itemNo = 0;
listAnalyzed = false;
name = string(node.attribute("name").value());
if (!string(node.name()).compare("list")) {
type = LIST;
count = 0;
} else {
type = SINGLE;
count = 1;
}
}
string Container::getName() {
if (type == SINGLE)
return name;
else
return "";
}
In my main.cpp, I have blow loop
Code:
for (xml_node tnode = it->first_child(); tnode ; tnode = tnode.next_sibling()) {
Container tmpContainer(tnode);
if (tmpContainer.getType() == SINGLE) {
string t = tmpContainer.getName();
moClassValueContainerVector[k].headerFields.push_back(t);
} else {
....
....
}
}
I cannot push_back(t). I examined the code with debugger, t has correct string value assigned, but even after 20-30 iterations, there is no element for headerFields vector. What is wrong here?
Thanks in advance...