Hi everyone,

I'm very happy you're discussed my thoughts ;-)

I suggested to use boost as I thought it was already used elsewhere. Now if 
it's not the case then we can use another way.
The key requierment is that we want to be able to use ("toto %something 
%somethingelse" arg1 arg2)ish syntax but with clean C++.

Now, one solution is to use boost::format

Another one would be to implement a Qt4-like arg in a subclass of std::string. 
Here is my suggestion:

class FormatableString : public std::string
{
        // level of argument, used for nested .arg()
        int argLevel;

        FormatableString(const std::string &s) :
                std::string(s),
                argLevel(0)
        {

        }       

        template <typename T>
        const FormatableString &arg(const T& value)
        {
                // transform value into std::string
                std::ostringstream oss;
                oss << value;

                // from here is pseudo code
                
                // find %argLevel in *this
                // if found,
                        // replace %argLevel by oss.str(), which is value 
transformed into string

                // end of pseuccode 

                // increment argLevel
                argLevel++,

                // return reference to this so that .arg can proceed further
                return *this;
        }
};

Opinions welcome

Steph


_______________________________________________
glob2-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/glob2-devel

Reply via email to