
From my point of view it isn't fair to compare one small streamline.h file ( 350 rows and no compilation is necessary) with your library, which consist of tens of files. This tiny file is doing almost the same job as your library, except formatting. It was my initial temptation to add additional
Thank you for leading me to your superb outfmt lib. parameter in argument list to manage format, something like that: struct fmt { char containerOpenBrackets; // '{' char elementOpenBrackets; // '(' char separator; // ',' char elementCloseBrackets; // ')' char containerCloseBrackets; // '}' }; Later on I have drop this attempt because the very concept of formatting has a lot of problems: 1) User can not read from the stream without prior knowledge of what type of formatting was used, when that stream was created. 2) Problems will came up, when one will stream out the container of strings and some of those strings can contain the chars, which were used for formatting as "[{,]}". The streaming out of such container will not cause any problems, but how to read it back? It is my opinion that Library can not rely on special treatment of any chars, except white-spaces " \t\n\r\v\f", which should be used as separators. It will be interesting to hear yours and the other people thoughts about this matter. Regards, Boris. P.S. The results of streaming out of const char *str="Hello"; should be Hello according to C-style. P.P.S. What is the problem to stream that item std::list< std::pair< std::string, std::string > > ? The streamline template will handle it and any other combinations of containers/pair/string/primitives easily. B.K. --- Reece Dunn <msclrhd@hotmail.com> wrote:
Boris Kats wrote:
I am using it for some time and hope that other will benefit from it. One file streamline.h will help user to stream out/in an arbitrary item of primitives or STL containers of them. It is very simple to use; just type like this:
#include "streamline.h" using namespace hekate; ....... typedef std::pair<std::string, std::vector<int> > element; element one,other; And stream it out as: streamline(cout,one); or stream it in as: streamline(cin,other); .
User will find a lot of examples in the streamtest.cpp file at streamline.tar in "Files section". The streaming templates were tested with gcc version 3.3.2, msvc7 and ibm89 c++ compiler. Boris Kats.
Hi Boris,
As Jonathan has pointed out, my library is aimed at solving this type of problem. Your example would become:
#include <sstream> #include <boost/outfmt/stl/vector.hpp> #include <boost/outfmt/stl/pair.hpp>
int main() { typedef std::pair< std::string, std::vector< int
element; element one, other;
one.first = "Meine \"Grosse\" Welt!"; one.second.push_back( 3 ); one.second.push_back( 6 ); one.second.push_back( 9 );
std::stringstream ss; ss << one; std::cout << "written: " << ss.str() << '\n'; ss >> other; std::cout << "read: " << other << '\n';
return( 0 ); }
Providing a much simpler syntax and stream integration. The output for this is: written: ( "Meine \"Grosse\" Welt!", [ 3, 6, 9 ] ) read: ( "Meine \"Grosse\" Welt!", [ 3, 6, 9 ] )
It is possible to control how the pair and vector types are rendered using a custom formatter. Refer to the examples and documentation for more information.
Regards, Reece
_________________________________________________________________
Check out Election 2004 for up-to-date election news, plus voter tools and more! http://special.msn.com/msn/election2004.armx
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
__________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail