glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [glob2-devel] Refactoring


From: Sébastien
Subject: Re: [glob2-devel] Refactoring
Date: Tue, 2 May 2006 08:31:10 +0200
User-agent: KMail/1.9.1

Le Lundi 1 Mai 2006 21:19, Stéphane Magnenat a écrit :
> 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
I'm ok
the format string would be something like this "Hello %1, Welcome to %2"
But we have to handle precision and radix for numbers (some are displayed in 
hexa)...
>
>
> _______________________________________________
> glob2-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/glob2-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]