Re: Why all the different string types?

"kaczoroj" <[email protected]> Thu, 09 Mar 2006 00:48:19 -0000
Newsgroups gmane.comp.version-control.cvs.gui.devel
Message-ID <[email protected]>
Guy,

Well, it helps if you use the doxygen-generated class diagram ;) To 
store anything you use the classes inheriting from CPersistent. 

For the simple string there are two classes with two defines:
#define CPStr UPStr
#define CStr UStr

Then you go to the source and you can see:

/// Up to 255 characters pascal and C string class
class UEXPORT UPStr{...}

/// C string class
class UEXPORT UStr {...}

> we have CPStr.cpp, which just to be mean defines PCPStr and PCStr, 
> but not CPStr at all.

P stands for Persistant. Simply stores the above CPStr and CStr 
classes. 

> There's UStr, CStr, CString, And some of the code uses std::string.

UStr is same as CStr. CString is an MFC classs used on Windows-
specific code. std::string used by me recently as I was trying to see 
how would that go if we tried to replace the above string classes with 
std::string. Mixed feelings about that one - std::string is by far the 
most crappy string class even invented. Unfortunately we can't use 
CString (which is superb) so we are stuck with UStr for now. I want to 
phase out UPStr (and consquently PCPStr) eventually.

> Then there's all the multistring variants: CMString, CMPString, 
> CKeyString, CMKeyString. 

/// CStr specialization of TMString
class CMString : public TMString<CStr> {...}

/// CPStr specialization of TMString
class CMPString : public TMString<CPStr> {..}

Where TMString:
template<class T>
class TMString : public CPersistent

This is a persistent multi-string. It can hold multiple strings and 
store them. Very usefull for things like combo boxes.

/// Dictionary specialization of TKeyString ('@')
class CKeyString : public TKeyString<'@'>

/// Multi-key specialization of TKeyString ('x01')
class CMKeyString : public TKeyString<'\x01'>

Where TKeyString
/// Multi-string for storing map (e.g. dictionary)
template <char delimiter>
class TKeyString : public CMString

CMKeyString is just for convienient storage of related dictionaries 
together, used to store various keywords in CVSROOT wizard.

> Are there any suggestions or guidelines on the appropriate 
> uses of these different string types?

Well, you can see how the classes are used and keep the same when 
making changes - it's not that complicated really. 

I would advise to use CStr rather than CPStr. 

I am still not sure about the migration to std::string so for now you 
can use either one whichever looks more comfortable. Any input on 
that? This will require writing and re-writing some tool routines and 
since std::string doesn't take NULLs it will cause some crashes until 
it's wired properly. But if the general feeling is to go with the 
standard we could do that.

I will see if I can organize all that a little bit better but if I do 
then it will break gCvs and MacCvs compilation so be prepared for a 
little catch-up ;)

Best Regards,
Jerzy







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/cvsgui-dev/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/