DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_string.h00001 /*****************************************************************************/ 00002 // Copyright 2006-2007 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/workarea/stern/camera_raw/dng_sdk/source/dng_string.h#10 $ */ 00010 /* $DateTime: 2008/01/11 19:42:32 $ */ 00011 /* $Change: 410954 $ */ 00012 /* $Author: stern $ */ 00013 00014 /*****************************************************************************/ 00015 00016 #ifndef __dng_string__ 00017 #define __dng_string__ 00018 00019 /*****************************************************************************/ 00020 00021 #include "dng_types.h" 00022 #include "dng_memory.h" 00023 00024 /*****************************************************************************/ 00025 00026 class dng_string 00027 { 00028 00029 private: 00030 00031 // Always stored internally as a UTF-8 encoded string. 00032 00033 dng_memory_data fData; 00034 00035 public: 00036 00037 dng_string (); 00038 00039 dng_string (const dng_string &s); 00040 00041 dng_string & operator= (const dng_string &s); 00042 00043 ~dng_string (); 00044 00045 const char * Get () const; 00046 00047 bool IsASCII () const; 00048 00049 void Set (const char *s); 00050 00051 void Set_ASCII (const char *s); 00052 00053 void Set_UTF8 (const char *s); 00054 00055 uint32 Get_SystemEncoding (dng_memory_data &buffer) const; 00056 00057 void Set_SystemEncoding (const char *s); 00058 00059 bool ValidSystemEncoding () const; 00060 00061 void Set_JIS_X208_1990 (const char *s); 00062 00063 static uint32 DecodeUTF8 (const char *&s, 00064 uint32 maxBytes = 6); 00065 00066 uint32 Get_UTF16 (dng_memory_data &buffer) const; 00067 00068 void Set_UTF16 (const uint16 *s); 00069 00070 void Clear (); 00071 00072 void Truncate (uint32 maxBytes); 00073 00074 bool TrimTrailingBlanks (); 00075 00076 bool TrimLeadingBlanks (); 00077 00078 bool IsEmpty () const; 00079 00080 bool NotEmpty () const 00081 { 00082 return !IsEmpty (); 00083 } 00084 00085 uint32 Length () const; 00086 00087 bool operator== (const dng_string &s) const; 00088 00089 bool operator!= (const dng_string &s) const 00090 { 00091 return !(*this == s); 00092 } 00093 00094 // A utility for doing case insensitive comparisons on strings... 00095 00096 static bool Matches (const char *t, 00097 const char *s, 00098 bool case_sensitive = false); 00099 00100 // ...wrapped up for use with dng_string. 00101 00102 bool Matches (const char *s, 00103 bool case_sensitive = false) const; 00104 00105 bool StartsWith (const char *s, 00106 bool case_sensitive = false) const; 00107 00108 bool EndsWith (const char *s, 00109 bool case_sensitive = false) const; 00110 00111 bool Contains (const char *s, 00112 bool case_sensitive = false, 00113 int32 *match_offset = NULL) const; 00114 00115 bool Replace (const char *old_string, 00116 const char *new_string, 00117 bool case_sensitive = true); 00118 00119 bool TrimLeading (const char *s, 00120 bool case_sensitive = false); 00121 00122 void Append (const char *s); 00123 00124 void SetUppercase (); 00125 00126 void SetLowercase (); 00127 00128 void SetLineEndings (char ending); 00129 00130 void SetLineEndingsToNewLines () 00131 { 00132 SetLineEndings ('\n'); 00133 } 00134 00135 void SetLineEndingsToReturns () 00136 { 00137 SetLineEndings ('\r'); 00138 } 00139 00140 void StripLowASCII (); 00141 00142 void ForceASCII (); 00143 00144 int32 Compare (const dng_string &s) const; 00145 00146 }; 00147 00148 /*****************************************************************************/ 00149 00150 #endif 00151 00152 /*****************************************************************************/ |