So there's a single StringValue class, but sometimes its type is
TYPE_UTF8_STRING and sometimes its type is TYPE_UTF16_STRING?  So calling
Value::IsType would require two checks to see what type of string it is? 

I think it would be easier if there was only one string type and
internally it keeps track of whether to use a std::string or std::wstring
(depending on which CreateString method was used).  If you call GetString
or GetWString, it'll do the conversion automatically if you created the
string using the other type. This makes it easier for consumers of the
code and shouldn't require changing any callers.



On Mon, 8 Dec 2008, Andrew Scherkus wrote:

> Somewhat in line with the Google style guide, the overloaded
> CreateStringValue/GetString do accomplish the same thing (variant string
> type), just with different encodings.
> I did some partial implementations of #3 and as Peter highlighted, writing
> GetWideString everywhere started looking really silly.
> 
> In terms of enums and implementation, would TYPE_STRING and TYPE_WSTRING
> suffice with documentation and DCHECKs for UTF-8 std::strings?
> 
> On Mon, Dec 8, 2008 at 8:09 PM, Brett Wilson <[EMAIL PROTECTED]> wrote:
> 
> >
> > On Mon, Dec 8, 2008 at 7:50 PM, Peter Kasting <[EMAIL PROTECTED]> wrote:
> > > On Mon, Dec 8, 2008 at 6:41 PM, Andrew Scherkus <[EMAIL PROTECTED]>
> > > wrote:
> > >>
> > >> Darin touched upon this, who said to document that std::string should
> > >> refer to UTF-8 strings.
> > >> How about:
> > >>  - CreateStringValue creates a StringValue object that returns
> > >> TYPE_UTF8_STRING and has a DCHECK(IsStringUTF8(foo)) in the constructor
> > >>  - CreateWideStringValue creates a WideStringValue object that returns
> > >> TYPE_UTF16_STRING
> > >
> > > To be honest, I probably lean more toward a single overloaded
> > > CreateStringValue().  I think having different function names decreases
> > > clarity and increases verbosity.  But it's not a big deal.
> > > However, if you go with two names, make the names match the TYPE_
> > returns:
> > > CreateUTF8StringValue() and CreateUTF16StringValue(), or something.
> >
> > Be careful because wstring != UTF16String.
> >
> > In other places of the code, we use GetWString, which if you're
> > returning a wstring, I think is the best naming convention (since
> > wstring changes type depending on the platform).
> >
> > Brett
> >
> > >
> >
> 
> > 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Chromium-dev" group.
To post to this group, send email to chromium-dev@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/chromium-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to