|
|
Comments and Discussions
|
|
 |

|
Hi,
Thanks for the code. I have found that error by accident. Sample of testing code below:
ParamIO outXml;
outXml.write("VIEWER:PARAM1", "abc");
outXml.write("VIEW:PARAM2", 1); // By accident typed VIEW instead of VIEWER
outXml.writeFile("filename.xml"); // Finally write the file to disk
The result will be:
<VIEW>
< PARAM1>abc</PARAM1>
< PARAM2>1</PARAM2>
</VIEW>
Second "write" call finds VIEWER node instead of VIEW node. After that it changes node name from VIEWER to VIEW and adds new parameter.
Best regards,
Gintas
|
|
|
|

|
I am getting the following error on first compile of the test project:
'static cast' : cannot convert from 'const XML_Node *' to 'XML_Node::nodes_const_iterator'
on the following two lines:
// First we need to find the final node
XML_Node::nodes_const_iterator res, end, begin;
begin = static_cast<XML_Node::nodes_const_iterator>(&_node);
end = static_cast<XML_Node::nodes_const_iterator>(&(_node) + 1);
It appears that _node is a private variable of type XML_Node in the XML_Param_Notify class. XML_Node::nodes_const_iterator is just a typedef defined as:
typedef std::vector<XML_Node>::const_iterator nodes_const_iterator;
So it looks like this code is trying to cast the address of _node into an iterator of type nodes_const_iterator. An iterator is just a pointer to an address right? It seems like this should be doable, and I'm guessing that since no one else has posted this problem yet it has something to do with what I'm doing on my end. Any ideas?
|
|
|
|

|
This was discussed in prior posting. VS.NET vs. VC++ 6.0. Change line 218 in VS.Net to: XML_Node::nodes_const_iterator res; XML_Node::nodes_const_iterator begin((std::vector<XML_Node>::_Tptr) &_node); XML_Node::nodes_const_iterator end((std::vector<XML_Node>::_Tptr)(&(_node) + 1));
|
|
|
|

|
Perhaps this has been talked a lot but I can not stop my self from writing this.
One of the reasons of XML is connecting platforms, apps through text encoded messages, to achieve this you need compliance. Implementing a fully (95%-98%) compliant XML parser is really hard. Usually an average Dev can get to 80% pretty quickly and the experienced can get to %90. The rest is all egde cases and getting them right requires extensive testing suites to ensure compat between different platforms. I know this by experience. There are quite a few xml parser implementations out there. Users are usually best served when the xml parser implementations are recognized by the W3C Recommendations. Other implementations can not go any further than academic studies as the cost of them making interop with the rest of the world sky rockets as dev's are trying to achieve %95 compat.
|
|
|
|

|
I'm having problems reading an xml file that looks like this, <PARAMS> <TEXT>Hello world</TEXT> <COLOR> <RED>50</RED> <GREEN>128</GREEN> <BLUE>255</BLUE> </COLOR> <COLOR> <RED>60</RED> <GREEN>188</GREEN> <BLUE>252</BLUE> </COLOR> </PARAMS> That is, if I have two or more color nodes, how would I read it using this program? It reads only the first one. Is it possible to read such kind of files using this application??? TIA http://www.TechiesAbode.com/
|
|
|
|

|
In XML_Node.h I had to add:
#include <sstream>
|
|
|
|

|
Cheers.
I upgraded to a new kernel, and got the
message when trying to recompile my code
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).
It solved the problem.
|
|
|
|

|
I am having trouble with reading in white spaces with this code. I can write strings that contain white spaces, but when I try to read them in, it only returns the first word. I'm assuming I'm not the only one out there with this problem, anyone have a fix?
Thanks!
|
|
|
|

|
Long time ago i made some big modification to ParamIO to support success of reading, Path and multiple nodes.
Something like this can be used:
if(!Cfg.read("/MyApp/Layout/Layer[2]/Type", type,""))
{
}
This also should work with write.
Maybe Arnud will put my code here in a separate archive.
Arnud please let me know if you are wiling to upload my code.
|
|
|
|

|
For sure! I'd be glad to upload your code, if you send it to me.
|
|
|
|

|
I tried adding the files XmlMode,XmlParser,XmlStream,ParamIO,Xml_Notify,XmlUtil both headers, and cpp files to a new Win32 console project with MFC support. I've got this linker errors any ideas?
xmltest error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj)
xmltest error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj)
...
|
|
|
|

|
Great codes! But in my usage, I have a problem,i.e. my program will call writeFile several times, so my data will be overwritten. For writeFile use the std::ofstream to write file, so existing file will be overwritten. I want to know: Is there any better way to avoid these?
Songge Info
|
|
|
|

|
HI,
how can i modified this source to make possible to write the key and the value from a database ? for reading,i should be load all keys and values in my database.
Thanks for your Reply.
best regards,
Dominique
|
|
|
|

|
Thanks for that Great Work!
David Hubbard wrote a great parser and you made it more usable. I need to write my own Config Writer, because I need some more functionality ( multiple entries of the same name, nesting of Setting into each other...), but the Functionality you added with the Handling for Nodes an Elements makes that quite easy.
Why did you add that CString support in such a nice "pure" STL Tool?
|
|
|
|

|
Thanks a lot for your support.
About CString, someone sent me an email with the changes to add the CString support because many people are interested in CString.
I want ParamIO to benefit as much as possible from other people, so I decided to add his code.
If you want to remove the CString support for your use, feel free to do it.
|
|
|
|

|
TheBigW, how is work on your 'multiple entries' progressing?
If ready, won't you write make it available on CodeProject?
thanks
nelis
|
|
|
|

|
Yes it has been finished a while ago. It is already in heavy use in my recent project.
But to write an articel I still have to review the code, doing some coments and so on I hope to find the time to finish it it this month. If you need it earlier I could send you the source as it is.
|
|
|
|

|
Hi, BigW,
If you can send me one copy of your code, appreciate that.
thanks
hello world
|
|
|
|

|
Hi, TheBigW, if I could get a copy of your code soon I'd really appreciate that, too
thanks,
boz
|
|
|
|

|
For all of you who needed to use many Keys of equal names at the same Level have a look at my (still brandnew) article at :
http://www.codeproject.com/useritems/XMLConfig.asp
I used the XML Attributes to solve the Problem. Maybe at is interesting for those who asked questions about that fact too.
|
|
|
|

|
how can i write 2 differents objekts in the same file, like this example.
ParamIO outXml , Xmlout;
outXml.write("PARAMS:COLOR:GREEN", _green);
outXml.write("PARAMS:COLOR:BLUE", _blue);
Xmlout.write("PARAMS:FONT:NAME", _fontName);
Xmlout.write("PARAMS:FONT:SIZE", _fontSize);
outXml.writeFile("filename.xml"); // Finally write the file to disk
Xmlout.writeFile("filename.xml");
i want to have _green, _blue ,_fontName, _fontSize in the filename.xml.
any idee ?
best regards,
Dominique
|
|
|
|

|
Hi All,
ParamIO does not currently compile under UNICODE. Has anyone made any (local) changes that they would be willing to share to make ParamIO UNICODE compliant?
Arnaud, I see below that you were going to have a look at what it would take to implement UNICODE compatibility. Have you had a chance to look into it at all?
Thanks!
--
Edward Livingston
(aka ExtraLean)
--
"I still maintain that seeing a nipple is far less disturbing than seeing someone get their brains blown out." -- Chris Maunder
|
|
|
|

|
Thought I'd mention that it seems like there are only 2 comiler errors when building in UNICODE.
Both are in ParamIO.h:
-------------------------------------
Line 92:
text = std::string(value); // Convert from CString to std::string.
error:
error C2440: 'type cast' : cannot convert from 'CString' to 'std::basic_string<_Emem,_Traits,_Ax>'
-------------------------------------
Line 148:
return read(str, value, (LPCSTR)defaultVal);
error:
error C2440: 'type cast' : cannot convert from 'CString' to 'LPCSTR' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
-------------------------------------
Hope this helps....
--
Edward Livingston
(aka ExtraLean)
--
"I still maintain that seeing a nipple is far less disturbing than seeing someone get their brains blown out." -- Chris Maunder
|
|
|
|

|
Hi,
I never had time to make some changes for UNICODE.
I guess that what you should do is change string to wstring and LPCSTR to LPCTSTR .
I'd suggest you have a look at http://www.codeproject.com/vcpp/stl/upgradingstlappstounicode.asp
it may give good ideas to make the changes.
Good luck!
Arnaud
|
|
|
|

|
Hi,
I am new to .NET and XML. I task is to read the xml, find a particular element, find the existance of particular attribute and if found then the attribute value should be updated with another value. I have to use vb.net using SAX parsers.
I could able to read the XML file using SAXXMLReader class but could not able to change the attribute value.
Can any help me sending the info regarding it.
I hope my problem is clear.
Thanks in advance.
Regards,
Sateesh.
|
|
|
|

|
I'm using this:
std::string _text = "test";
ParamIO outXml;
outXml.write("PARAMS:TEXT", _text);
outXml.writeFile("Save.xml");
and getting this:
Compiling...
SquadServ.cpp
D:\Tauri\SquadServ\SquadServ.cpp(83) : warning C4003: not enough actual parameters for macro 'write'
D:\Tauri\SquadServ\SquadServ.cpp(83) : error C2039: 'send' : is not a member of 'ParamIO'
d:\tauri\squadserv\paramio.h(30) : see declaration of 'ParamIO'
D:\Tauri\SquadServ\SquadServ.cpp(83) : error C2059: syntax error : ','
Error executing cl.exe.
what should I do ?
|
|
|
|

|
instead of:
outXml.write("PARAMS:TEXT", _text);
do:
outXml.write("PARAMS:TEXT", _text.c_str());
~Nitron.
ññòòïðïðB A start
|
|
|
|

|
Just what I needed, thanks!
~Nitron.
ññòòïðïðB A start
|
|
|
|

|
Hi,
I have read whole discussion about this library, but I cannot solve my problem. I wrote to all .cpp files the stdafx.h and set to static library. But during compilation, it returns 252 errors. The first & the most important(I think) is in ParamIO.cpp: ParamIO is not a class or a namespace name. All other errors are depending on this one. I don't know what to do...
|
|
|
|

|
Hi,
can you explain the problem by giving the output of the compiler?
I'm sure it's a small difference that makes all the errors.
First of all, can you compile properly the provided sample application?
I'll try to do my best to help you, but I don't have VC++ at the moment so I can't try many things.
Arnaud
|
|
|
|

|
Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP43D.tmp"
Output Window
Compiling...
ParamIO.cpp
D:\programming\C++projects\Polus\ParamIO.cpp(4) : error C2653: 'ParamIO' : is not a class or namespace name
D:\programming\C++projects\Polus\ParamIO.cpp(4) : error C2653: 'std' : is not a class or namespace name
D:\programming\C++projects\Polus\ParamIO.cpp(4) : error C2061: syntax error : identifier 'vector'
D:\programming\C++projects\Polus\ParamIO.cpp(6) : error C2065: 'access' : undeclared identifier
D:\programming\C++projects\Polus\ParamIO.cpp(6) : error C2228: left of '.clear' must have class/struct/union type
D:\programming\C++projects\Polus\ParamIO.cpp(13) : error C2653: 'std' : is not a class or namespace name
D:\programming\C++projects\Polus\ParamIO.cpp(13) : error C2065: 'istringstream' : undeclared identifier
D:\programming\C++projects\Polus\ParamIO.cpp(13) : error C2146: syntax error : missing ';' before identifier 'stream'
D:\programming\C++projects\Polus\ParamIO.cpp(13) : error C2065: 'stream' : undeclared identifier
D:\programming\C++projects\Polus\ParamIO.cpp(17) : error C2228: left of '.getline' must have class/struct/union type
D:\programming\C++projects\Polus\ParamIO.cpp(17) : fatal error C1903: unable to recover from previous error(s); stopping compilation
XML_Node.cpp
D:\programming\C++projects\Polus\XML_Node.cpp(5) : error C2653: 'XML_Node' : is not a class or namespace name
D:\programming\C++projects\Polus\XML_Node.cpp(7) : error C2550: 'XML_Node' : constructor initializer lists are only allowed on constructor definitions
.... & much more...
I'm sure that it is very small problem, but very hide for me \-:
Sample app is not problem for me to compile. It is work properly.
|
|
|
|

|
Hi,
try the following:
At the beginning of ParamIO.cpp, put
#include
std::vector testVec;
And check if those lines create an error. If they do, then you have a problem with your STL installation.
If not, do you have #include "ParamIO.h" at the beginning of ParamIO.cpp ?
Arnaud
|
|
|
|

|
Thanx, I have solved the problem - I hadn't got stdafx.h on first line!
|
|
|
|

|
The primary reason being that there is an assumption in the code that vector::iterator and its chums are implemented as pointers to T. As far as I know this has previously been the case with VC++ but the C++ standard does not guarantee this.
Ben
|
|
|
|

|
I replaced the code in XML_Node.cpp line 218
XML_Node::nodes_const_iterator res, end, begin;
begin = static_cast<XML_Node::nodes_const_iterator>(&_node);
end = static_cast<XML_Node::nodes_const_iterator>(&(_node) + 1);
with
XML_Node::nodes_const_iterator res;
XML_Node::nodes_const_iterator begin((std::vector<XML_Node>::_Tptr) &_node);
XML_Node::nodes_const_iterator end((std::vector<XML_Node>::_Tptr)(&(_node) + 1));
it seams to work but since I’m not a stl guru I don't know if is the correct way.
|
|
|
|
|

|
Good stuff. It worked, Thanks. However, there is a capsing typo when yooy wrote xml instead of XML. THe fix is below:
XML_Node::nodes_const_iterator res;
XML_Node::nodes_const_iterator begin((std::vector<XML_Node>::_Tptr) &_node);
XML_Node::nodes_const_iterator end((std::vector<XML_Node>::_Tptr)(&(_node) + 1));
Thanks
|
|
|
|

|
it works perfectly, thank you very much!
be lazier, be cleverer!
|
|
|
|

|
thanks for the great XML tools, they are very easy to use. I would like to have a table represented in XML but this implementation of the parser doesn't handle multiple entries of the same name, for example: <HOST> <NAME>cod</NAME> <DNSNAME>cod.somecorp.com</DNSNAME> <NIC> <MAC>0040f4612820</MAC> <IP>192.168.172.54</IP> <IP>192.168.173.54</IP> </NIC> </HOST> <HOST> <NAME>drum</NAME> <DNSNAME>drum.somecorp.com</DNSNAME> <NIC> <IP>192.168.172.47</IP> </NIC> </HOST> in this example the <HOST> and <IP> tags both have multiple entries. the XMLDialog displays the host cod for both entries, and only 1 IP address, it would be nice to be able to address these in the read/write methods like: "HOST[0]:NIC:IP[1]","192.168.173.54" --Ben Burnett
|
|
|
|

|
Yeah .. I need it too .. Maybe I can add one <Count>XX</Count> element within each Section like below <HOST_1>...</HOST_1> <HOST_XX>..</HOST_XX> Sorry .. suck idea .. ><"
|
|
|
|

|
Hello Arnaud, thank you your article to read and write parameters in XML. I test the code to read strings, integer and double values from my xml files. Everything is working well. Is there any possibility to read/write integer or double arrays? Best regards Dieter Welter Dieter Welter
|
|
|
|

|
Hi all,
I updated the code of ParamIO.
I added support for CString, and a method to erase an element of a node.
Arnaud
|
|
|
|

|
Hi Arnaud, The code doesn't compile in Visual Studio .NET The message is: XML_Node.cpp c:\Workshop\XML&DB\STL XML instead of INI\ParamIO_Demo\XML_Node.cpp(215) : error C2440: 'static_cast' : cannot convert from 'const XML_Node *' to 'XML_Node::nodes_const_iterator' No constructor could take the source type, or constructor overload resolution was ambiguous c:\Workshop\XML&DB\STL XML instead of INI\ParamIO_Demo\XML_Node.cpp(216) : error C2440: 'static_cast' : cannot convert from 'const XML_Node *' to 'XML_Node::nodes_const_iterator' No constructor could take the source type, or constructor overload resolution was ambiguous I couldn't find a quick solution for this problem Could you please help? Thanks, Vladimir
|
|
|
|

|
Hi Vladimir,
I made this modification in the XML_Param_Notify code and it seems to work properly now.
hope this will be usefull for you.
Vinz.
//in XML_Param_Notify
//declaration
private:
XML_Node *_currentNodeTarget;//target the current node object
//definition
XML_Param_Notify::XML_Param_Notify():
_currentNode(0)
{
_currentNodeTarget=&_node;
}
XML_Node::nodes_const_iterator XML_Param_Notify::getNode(std::vector &strs) const
{
// First we need to find the final node
XML_Node::nodes_const_iterator res, end, begin;
int iTemp;
begin=static_cast<XML_Node::nodes_const_iterator>(_currentNodeTarget);
end=static_cast<XML_Node::nodes_const_iterator>((_currentNodeTarget)+1);
res = begin;
for(int i=0; igetName();
res = std::find_if(begin, end, FindNode(strs[i]));
}
if(res == end)
{
// Couldn't find the proper parameter
return static_cast<XML_Node::nodes_const_iterator>(0);
}
begin = res->beginNodes();
end = res->endNodes();
}
return res;
}
XML_Node::nodes_iterator XML_Param_Notify::getNode(std::vector &strs)
{
// First we need to find the final node
XML_Node::nodes_iterator res, end, begin;
begin = static_cast<XML_Node::nodes_iterator>(_currentNodeTarget);//&_node);
end = static_cast<XML_Node::nodes_iterator>(_currentNodeTarget+1);//&(_node) + 1);
res = begin;
for(int i=0; i(0);
}
begin = res->beginNodes();
end = res->endNodes();
}
return res;
}
VinZ
|
|
|
|

|
I don't see any difference with the last code from November 2002. Could you please post the update.
Thanks
|
|
|
|

|
Hi Arnaud,
it works still not with CString. Are you sure that you have post the Update?
thank you for your share!
Deukath
Deu
|
|
|
|

|
I just want to remove a XML tag. For example the <COLOR></COLOR> tag. I tried to write an empty string, but this doesn't work. The append and update operations work fine, but I need to remove a parameter.
|
|
|
|

|
I looked at the code and found that there is a function for clearing of a XML Node (XML_Node::clear()). It works but clears the entire tree. I need a function that will clear only an Element or SubTree. Is it possible to set my Element data in the _name, _attributes and _parent variables below. void XML_Node::clear() { _name = std::string(); _attributes = std::string(); _parent = 0; _elements.clear(); _nodes.clear(); } Any help is appreciated.
|
|
|
|

|
Hi,
sorry for having you wait for a reply.
I never thought about adding such a feature, but I think it's a very natural one. I'll try to add it today and update the website.
Arnaud
|
|
|
|

|
Hello,
i´m looking for a simple to use XML-Class and find ParamIO, it looks very nice. But i have some problems with it.
Linker errors occur, when i try to compile my project with static linked MFC and i couldn´t use precompiled header files.
Another thing is that i have memory leaks, when i close the app.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
This article provides an easy way to load and save the parameters of an application in XML format.
| Type | Article |
| Licence | |
| First Posted | 30 Apr 2001 |
| Views | 471,751 |
| Bookmarked | 133 times |
|
|