473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Need template for list of name/value pairs

Further to a question I posted here recently about coding an xml rpeort
parser, I need to use a list of name/value pairs, in this case, a list
property names and values for a given tag.

Rather than deriving a linked list class and adding in 2 char * to the
derived class, I have decided to try and start using templates howver
not having used templates before I do not know where to start.
Unfortunately time is not on my side and I was hoping someone could give
me a quick kick start with how to declare such a template.

Deriving from my own base list and list element classes is obviously an
easy task however I would like to start using templates at some point
and this would be something easy to get me started.

Any help or pointers would be rgeatly appreciated.

Thanks in advance
Jul 19 '05 #1
7 5346
Woodster wrote:
Further to a question I posted here recently about coding an xml
rpeort parser, I need to use a list of name/value pairs, in this case,
a list property names and values for a given tag.

Rather than deriving a linked list class and adding in 2 char * to the
derived class, I have decided to try and start using templates howver
not having used templates before I do not know where to start.
Unfortunately time is not on my side and I was hoping someone could
give me a quick kick start with how to declare such a template.

Deriving from my own base list and list element classes is obviously
an easy task however I would like to start using templates at some
point and this would be something easy to get me started.

Any help or pointers would be rgeatly appreciated.


Any reason to not use a standard class, like
std::map<std::string, std::string> ?

Jul 19 '05 #2
In article <MP************************@news.westnet.com.au> , mirror@
127.0.0.1 says...
Further to a question I posted here recently about coding an xml rpeort
parser, I need to use a list of name/value pairs, in this case, a list
property names and values for a given tag.


It sounds to me like you want a multimap of maps of pairs of strings.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #3
In article <bn*************@news.t-online.com>, ra******@t-online.de
says...
Any reason to not use a standard class, like
std::map<std::string, std::string> ?


No - no reason not to. Just having not used templates at all before
previously I am looking for pointers to a crash course in how to get
templates to do what I am after.

Regards

Woodster
Jul 19 '05 #4
In article <MP************************@news.clspco.adelphia.n et>,
jc*****@taeus.com says...
In article <MP************************@news.westnet.com.au> , mirror@
127.0.0.1 says...
Further to a question I posted here recently about coding an xml rpeort
parser, I need to use a list of name/value pairs, in this case, a list
property names and values for a given tag.


It sounds to me like you want a multimap of maps of pairs of strings.


Well, I have a list of tags that I need to parse, and each of these tags
can have it's own individual properties as well as standard properties
that will apply to every tag.

Regards

Woodster
Jul 19 '05 #5

"Woodster" <mi****@127.0.0.1> wrote in message
news:MP************************@news.westnet.com.a u...
In article <bn*************@news.t-online.com>, ra******@t-online.de
says...
Any reason to not use a standard class, like
std::map<std::string, std::string> ?


No - no reason not to. Just having not used templates at all before
previously I am looking for pointers to a crash course in how to get
templates to do what I am after.

Regards

Woodster


Any decent C++ book (non extensive e.g. Accelerated C++, TC++L, Thinking
C++,...) should cover the map/multimap classes you're looking for. Otherwise
I'd strongly recommend "The C++ standard library" by Nicolai Josuttis.

Regards
Chris
Jul 19 '05 #6
In article <MP************************@news.westnet.com.au> , mirror@
127.0.0.1 says...

[ ... ]
Well, I have a list of tags that I need to parse, and each of these tags
can have it's own individual properties as well as standard properties
that will apply to every tag.


Okay, so what do you need help with?

A map will allow you to specify one piece of data as a key, and another
piece of data that's associated with that key. A multimap is the same,
except that a single key can have an arbitrary number of pieces of data
associated with it.

It sounds to me like your problem maps to this fairly easily. What
attempted so far, and what problems have arisen?

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #7
In article <MP***********************@news.clspco.adelphia.ne t>,
jc*****@taeus.com says...
Okay, so what do you need help with?

A map will allow you to specify one piece of data as a key, and another
piece of data that's associated with that key. A multimap is the same,
except that a single key can have an arbitrary number of pieces of data
associated with it.

It sounds to me like your problem maps to this fairly easily. What
attempted so far, and what problems have arisen?


At the moment I have just placded the tags in the code where I needed
them and just did a comparison against that. The problem with this is
that it makes adding new tags more complicated as I need to add tags to
more than one place. I wanted to use the mapping so I had one central
list of tags.

Rather than base everything on a linked list, I thought now would be a
good time to start using templates and was chasing a kick in the right
direction which seems to be that I need to use std::map.

All I need now is to do a bit of internet searching for hints and tips
on exactly where to start with std::map
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kent Tenney | last post by:
Howdy, I am using PIL, and would like to make a list of the pixel values in an image, sorted by quantity of pixels with that value. im.histogram() returns a list which is a pixel count for...
5
by: Bernard | last post by:
Hi, I have a problem with a CGI script (Perl) on a Win2000 server. The script is for sending E-cards and was written by Jason Maloney:...
1
by: Daniel Etzold | last post by:
Hi, I have something similar to this: template< typename X, typename Y, typename T = std::map< X, Y > > class A { T _t; }; T may be a sequence of pairs or an associative container, e.g.
1
by: sommarlov | last post by:
Hi everyone >From one of our systems an xml file is produced. I need to validate this file before we send it to an external system for a very lenghty process. I cannot change the xml file layout....
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
6
by: naknak | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
3
by: aiooua | last post by:
Any idea why the following code does not compile? ---- #include<iostream> #include<list> using namespace std; class Base { public: int val;
4
by: Jonathan Wood | last post by:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages. The sample contains the following within the <headtag: <script type="text/javascript" src="flashobject.js"></script>...
6
by: shapper | last post by:
Hello, I am creating a form that includes a few JQuery scripts and TinyMCE Editor: http://www.27lamps.com/Beta/Form/Form.html I am having a few problems with my CSS: 1. Restyling the Select
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.