src/foundation/ZString.h

00001 /*  @(#) $Id: ZString.h,v 1.16 2006/07/23 22:00:42 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2000 Andrew Green and Learning in Motion, Inc.
00005 http://www.zoolib.org
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 ------------------------------------------------------------ */
00024 
00025 #ifndef __ZString__
00026 #define __ZString__ 1
00027 #include "zconfig.h"
00028 
00029 #include <cstdarg>
00030 #include <string>
00031 
00032 #include "ZTypes.h" // for uint64
00033 
00034 #if ZCONFIG_TempResourceHack
00035 namespace ZString {
00036 // A hack to aid migration
00037 #define sFromStrResource(a) sTranslateMacro(__FILE__, #a)
00038 #define FromStrResource(a) sTranslateMacro(__FILE__, #a)
00039 
00040 string sTranslateMacro(const char* inFileName, const char* inStringName);
00041 } // namespace ZString
00042 #endif // ZCONFIG_TempResourceHack
00043 
00044 namespace ZString {
00045 std::string FromStrResource(short iStringID);
00046 std::string sFromStrResource(short iStringID);
00047 } // namespace ZString
00048 
00049 // ==================================================
00050 
00051 class ZStreamR;
00052 class ZStreamW;
00053 
00054 namespace ZString {
00055 
00056 std::string sFormat(const char* inString, ...);
00057 std::string sFormat(const char* inString, va_list iArgs);
00058 
00059 std::string sSubstitute(const std::string& iString,
00060         const std::string& iS0);
00061 
00062 std::string sSubstitute(const std::string& iString,
00063         const std::string& iS0,
00064         const std::string& iS1);
00065 
00066 std::string sSubstitute(const std::string& iString,
00067         const std::string& iS0,
00068         const std::string& iS1,
00069         const std::string& iS2);
00070 
00071 std::string sSubstitute(const std::string& iString,
00072         const std::string& iS0,
00073         const std::string& iS1,
00074         const std::string& iS2,
00075         const std::string& iS3);
00076 
00077 std::string sSubstitute(const std::string& iString,
00078         const std::string& iS0,
00079         const std::string& iS1,
00080         const std::string& iS2,
00081         const std::string& iS3,
00082         const std::string& iS4);
00083 
00084 std::string sSubstitute(const std::string& iString,
00085         const std::string* iParams, size_t iParamsCount);
00086 
00087 int sComparei(const std::string& iLeft, const std::string& iRight);
00088 bool sEquali(const std::string& iLeft, const std::string& iRight);
00089 bool sContainsi(const std::string& iTarget, const std::string& iCandidate);
00090 
00091 std::string sMacizeString(const std::string& iString);
00092 
00093 std::string sFromInt(int iVal);
00094 int sAsInt(const std::string& iString);
00095 
00096 std::string sHexFromInt(int iVal);
00097 std::string sHexFromUInt64(uint64 iVal);
00098 
00099 std::string sFromUInt64(uint64 iVal); // Why uint64 and not int64?
00100 uint64 sAsUInt64(const std::string& iString);
00101 
00102 void sToStream(const std::string& iString, const ZStreamW& iStream);
00103 void sFromStream(std::string& outString, const ZStreamR& iStream);
00104 std::string sFromStream(const ZStreamR& iStream);
00105 
00106 std::string sFresh(const std::string& iOther);
00107 void sMakeFresh(std::string& ioString);
00108 
00109 const unsigned char* sAsPString(const std::string& iString);
00110 std::string sFromPString(const unsigned char* iPString);
00111 void sToPString(const std::string& iString, unsigned char* oPString, size_t iMaxLength);
00112 void sToPString(const char* iString, unsigned char* oPString, size_t iMaxLength);
00113 
00114 } // namespace ZString
00115 
00116 #endif // __ZString__

Generated on Thu Jul 26 11:21:51 2007 for ZooLib by  doxygen 1.4.7