Answer the question
In order to leave comments, you need to log in
Storing a list of parameters that can be referred to by name
There is a certain list of parameters in the form of a string set. To be clearer, it looks like a response header from a web server, i.e. format " parameter_name: value\r\n ". At least one parameter is stored.
The task is to store a list of parameters with their names and values, as well as to quickly search for the value of the required parameter by its name.
For example, there is a list:
And there should be analogies of commands:
I'm interested in ready-made solutions for organizing storage and retrieval. I have already considered several options: boost.property_tree - this library implements methods for working with xml, ini, info, json formats - there is no one suitable for me here. If you use this container, you will have to write your own parser. hash tables
параметр1: значение1\r\n
параметр2: значение2\r\n
getValueByName("параметр2");
addNewValueToList(param_list, "параметр37", "значение37");
- a table of correspondences is created by the name of the parameter. Based on this, you can figure something out, but I still don’t like something about this method;
storage in an array - this option is less interesting to me as the most raw. Here you will have to write all the functions yourself.
Tell me what should I choose. Can you suggest a better option.
Answer the question
In order to leave comments, you need to log in
Storage - hash tables (or std::map, if there are no performance problems).
Parsing is another matter.
I would also use hash tables - in g++ there is a hash_table class, in ms c++ it seems to be the same, but I'm not sure for sure.
Thanks to all. I will learn then hash tables. there seems to be no other choice. Parser, so be it, I'll write it manually then.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question