J
JustSomeGuy
I have a class that looks something like this (Don't try to compile it,
I haven't tested this)
class KVP
{
string key;
string value;
list<KVP> sublist;
};
class MyClass
{
private:
list<KVP> list;
public:
void parseInput(void);
};
My input looks something like.
a=b (Where a is the key and b is the value.)
c=e
d=e
b=c
f=g
h=j
k=l
So the number of tabs tells me how deeply nested I am.
I entend to implement this using a stack of KVPs.
void MyClass:arseInput(KVP & current)
{
int c;
while ((c = getchar()) != EOF)
{
if (c == '\t')
parseInput(list.front().sublist);
else
{
current.key = getkey();
current.value = getvalue();// get the key and value upto and
including the newline...
}
}
}
Of course at some point (the first call to parseInput needs 'this' as a
paramter...
Question is how do i know when to return and pop up to previous level?
When do I push_back the current to the list?
Got any tips or suggestions on how to do this?
I haven't tested this)
class KVP
{
string key;
string value;
list<KVP> sublist;
};
class MyClass
{
private:
list<KVP> list;
public:
void parseInput(void);
};
My input looks something like.
a=b (Where a is the key and b is the value.)
c=e
d=e
b=c
f=g
h=j
k=l
So the number of tabs tells me how deeply nested I am.
I entend to implement this using a stack of KVPs.
void MyClass:arseInput(KVP & current)
{
int c;
while ((c = getchar()) != EOF)
{
if (c == '\t')
parseInput(list.front().sublist);
else
{
current.key = getkey();
current.value = getvalue();// get the key and value upto and
including the newline...
}
}
}
Of course at some point (the first call to parseInput needs 'this' as a
paramter...
Question is how do i know when to return and pop up to previous level?
When do I push_back the current to the list?
Got any tips or suggestions on how to do this?