Use of dollar signs in variable names when using boost::archive::xml_iarchive
I have found a bug or undocumented limitation in the boost serialization
library.
I'm using VC++ 2003, which allows you to use variable names which include
dollar signs ($).
Variables with names containing dollar signs can be saved to an archive
using the boost::archive::xml_oarchive class.
When boost::archive::xml_iarchive is used to reload the variable, however,
the parsing of the variable name fails, and
basic_xml_iarchive<Archive>::load_start(const char *name) calls
boost::throw_exception( archive_exception(archive_exception::stream_error)
).
For example,
std::string filename( "C:\\dollar.txt" );
int $(0);
{
std::ofstream archive_file( filename.c_str() );
if( archive_file.good() )
{
boost::archive::xml_oarchive output_archive(archive_file);
output_archive << BOOST_SERIALIZATION_NVP( $ );
}
}
produces the following file:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
lloyd.reed@leica-microsystems.com wrote:
I have found a bug or undocumented limitation in the boost serialization library.
I'm using VC++ 2003, which allows you to use variable names which include dollar signs ($).
Is this a great idea? My reference Stroustrup - The C++ Programming language, page 81 says "Extensions (e.g. allowing the character $ in a name) yield non-portable programs." Robert Ramey
Actually, I checked my most recent version of the code (already checked into CVS). As a side effect from addressing a different but similar situation, this problem shouldn't occur in the future (1.33+). Robert Ramey Robert Ramey wrote:
lloyd.reed@leica-microsystems.com wrote:
I have found a bug or undocumented limitation in the boost serialization library.
I'm using VC++ 2003, which allows you to use variable names which include dollar signs ($).
Is this a great idea? My reference Stroustrup - The C++ Programming language, page 81 says "Extensions (e.g. allowing the character $ in a name) yield non-portable programs."
Robert Ramey
participants (2)
-
lloyd.reed@leica-microsystems.com
-
Robert Ramey