I am having an issue with my multimap insert. I have looked high and low for a possible solution to this problem. What I am trying to do is make an dynamic hierarchy data structure that has a root element then child elements under it holding values. I thought using a 3 dimensional multimap would be the best way but hey I am still a newbie. If you can think of a more efficient way to do it I am all for it.

a sample of the data is:

me {
	name: stats.devish.net;
	desc: DNet Stats Server;
	numeric: 343;
	bind: ipAddress;
	quitprefix: Quit:;
};
connect {
	host: ipAddress;
	port: 7867;
	pass: ********;
}

What I am having problems is the line that is inserting the child elements into the higharchy on line 13 below.

// storage class for our dynamic conf blocks
std::set<const char*> block_names;
std::set< const char*>::iterator blockit;

//storage class for block elements

typedef std::multimap<const char*,const char*> eTYPE;
std::multimap<const char*, eTYPE > blocks;
void Conf::Run()
{
//populate "me" core block
Conf::addClass("me");
blocks.insert(std::multimap::value_type("me", eTYPE::value_type("name", "dnet")));


//populate "connect" core block
Conf::addClass("connect");

}

If you need anything from me let me know. Thank you for your time. :)

What is the error you are getting? Can you provide the smallest compilable piece of code that will produce this error, along with sample input, expected output, and current output?

Dave

Here is the error:

make -C src  dnetstats
g++ -pipe -fPIC -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute -Wall -g1 -I/home/matthew/svn/dnetstats/src/include -pedantic -c confreader.cpp
confreader.cpp: In member function ‘void Conf::Run()’:
confreader.cpp:34: error: ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::multimap’ used without template parameters
make[1]: *** [confreader.o] Error 1
make: *** [server] Error 2

In me previous post I included the sample data which will be my input. As for expected result is that the value from the child elements to be dynamically stored in memory like a multimap would as for current output there is none do to the server is just initializing and it will be reading the conf file after it loads the higharchy to validate if there is any missing elements in the conf file. I am sorry if I did not include enough of my source in my previous post. I thought I have included all the definitions and declarations of the variables and functions you needed on a minimal scale.

btw I have attched the source so you can see what line 34 does.

Sorry.

I was able to solve this problem using this sample code below:

typedef struct {
     const char* element;
     const char* value;
} elem;

multimap<const char*, elem> t;
int main(int argc, char** argv) {
    elem data;
    data.element = "a";
    data.value = "c";
    t.insert(pair<const char*, elem>("b",data));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.