This is probably trivial, however... it has be befuddled:
I have a TinyXML document that I need to copy/move to a memory buffer. (Don't ask:) I don't seem to be able to get the .Print to work with a streamBuffer, etc. Any solutions / suggestions, methods, etc greatly appreciated.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get the following error message:
c:\Dvr\eClient\Config.cpp(334): error C2027: use of undefined type 'std::basic_ostringstream<_Elem,_Traits,_Alloc>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
Config.cpp(334) : see reference to class template instantiation 'std::basic_ostringstream<_Elem,_Traits,_Alloc>' being compiled
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
I'm using Visual Studio V7 on XP.
Thanks very much for your help!
-rz.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you are adventureous, there are patches (in the Patches section) to do this as well. It's a common feature request to have an API for this - one we'll consider for the next version.
lee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, normally you would click "Patches" above, then "Save xml to memory buffer path for release 2.3.4". And then it would depend on what kind of patch it is.
But since the patch doesn't seem to have a file attached (submitter forgot it?) it isn't going to work regardless. :) And hopefully you are on 2.4 in any case.
The STL solution (from Yves, above) is the way to go on STL. If you are not using STL, I would suggest saving to a temp file and then reading the temp file to a memory buffer.
lee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hmmm...
Apparently, I'm missing something (perhaps a large portion of my cerbral cortex or other large bundle of neurons:), but my compiler complains : binary '<<': no operator found which takes a righ-hand operand of type 'TiXmlNode' (or there is no acceptable conversion).
My (relevant) code below, which I believe to be almost verbatim the earlier solution (with context). When I remove the dereference (i.e., << rootnode ), it compiles, but the output is a single hex num (the address of the node).
What am I missing, or do I just need a firm whack on the side of the head?
Thanks everyone for your help and especially patience...
-rz.
//Parse the XML file and load member vectors
if ( !doc.LoadFile( "users.xml" ) )
{
printf( "EDVRCLIENT: mainFrame::ReadConfig config file not found\n" );
return 0;
}
Well, sort of... That was part of the problem, having the
#include <tinystr.h> before the <tinyxml.h> wasn't helping either...
Thanks everyone for your patience, AND your help. It is greatly appreciated (as is this software).
Perhaps when one or more of the plethora of fires burning is extinguished, I'll be able to reflect on all this and recoil in horror at how <expletive> stupid I have been.
'Til then...
Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is probably trivial, however... it has be befuddled:
I have a TinyXML document that I need to copy/move to a memory buffer. (Don't ask:) I don't seem to be able to get the .Print to work with a streamBuffer, etc. Any solutions / suggestions, methods, etc greatly appreciated.
Thanks!
Here's the function I'm using :
std::string get_xml_string (const TiXmlNode * node)
{
std::string s;
std::ostringstream os_stream (std::ostringstream::out);
os_stream << * node;
s = os_stream . str ();
return s;
}
Thanks!
... but... more idiocy (on my part:)...
I get the following error message:
c:\Dvr\eClient\Config.cpp(334): error C2027: use of undefined type 'std::basic_ostringstream<_Elem,_Traits,_Alloc>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
Config.cpp(334) : see reference to class template instantiation 'std::basic_ostringstream<_Elem,_Traits,_Alloc>' being compiled
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
I'm using Visual Studio V7 on XP.
Thanks very much for your help!
-rz.
You may just miss the following headers :
#include <iostream>
#include <sstream>
If you are adventureous, there are patches (in the Patches section) to do this as well. It's a common feature request to have an API for this - one we'll consider for the next version.
lee
I'd like to be adventureous, but -- um, how?
I don't see any file/patch although there is a patch entry is listed in the patches section.
1). what do I download (from where)?
2). what do I do with it after I download it?
Stupidity continues...
Thanks!
Well, normally you would click "Patches" above, then "Save xml to memory buffer path for release 2.3.4". And then it would depend on what kind of patch it is.
But since the patch doesn't seem to have a file attached (submitter forgot it?) it isn't going to work regardless. :) And hopefully you are on 2.4 in any case.
The STL solution (from Yves, above) is the way to go on STL. If you are not using STL, I would suggest saving to a temp file and then reading the temp file to a memory buffer.
lee
hmmm...
Apparently, I'm missing something (perhaps a large portion of my cerbral cortex or other large bundle of neurons:), but my compiler complains : binary '<<': no operator found which takes a righ-hand operand of type 'TiXmlNode' (or there is no acceptable conversion).
My (relevant) code below, which I believe to be almost verbatim the earlier solution (with context). When I remove the dereference (i.e., << rootnode ), it compiles, but the output is a single hex num (the address of the node).
What am I missing, or do I just need a firm whack on the side of the head?
Thanks everyone for your help and especially patience...
-rz.
int initConfiguration( void )
{
TiXmlNode * rootnode = 0;
TiXmlDocument doc;
TiXmlElement * usersElement = 0;
TiXmlElement * userItem = 0;
char * p;
char * name;
char * uid;
char * pwd;
char * plvl;
int num_users = 0;
std::string s;
std::ostringstream os_stream (std::ostringstream::out);
//Parse the XML file and load member vectors
if ( !doc.LoadFile( "users.xml" ) )
{
printf( "EDVRCLIENT: mainFrame::ReadConfig config file not found\n" );
return 0;
}
rootnode = doc.FirstChild( "config" );
if ( rootnode )
{
usersElement = static_cast<TiXmlElement*> ( rootnode->FirstChild( "users" ) );
if ( usersElement )
{
userItem = static_cast<TiXmlElement *>( usersElement->FirstChild( "user" ) );
while ( userItem )
{
num_users++;
name = (char *)userItem->Attribute( "name" );
uid = (char *)userItem->Attribute( "userid" );
pwd = (char *) userItem->Attribute( "password" );
userItem = static_cast<TiXmlElement*>( userItem->NextSibling( "user" ) );
}
}
}
os_stream << (* rootnode);
s = os_stream.str();
cout << s << endl;
return true;
}
I think you need to turn on STL support. :)
#define TIXML_USE_STL
And be sure to read the docs on "Using STL".
lee
AHA!
Well, sort of... That was part of the problem, having the
#include <tinystr.h> before the <tinyxml.h> wasn't helping either...
Thanks everyone for your patience, AND your help. It is greatly appreciated (as is this software).
Perhaps when one or more of the plethora of fires burning is extinguished, I'll be able to reflect on all this and recoil in horror at how <expletive> stupid I have been.
'Til then...
Thanks again.