56#include <wx/datetime.h>
57#include <wx/tokenzr.h>
59#include <wx/wxcrtvararg.h>
60#include <wx/convauto.h>
85 m_pString = String ?
new wxString(String) :
new wxString;
90 m_pString = String ?
new wxString(String) :
new wxString;
95 m_pString =
new wxString(Character, nRepeat);
100 m_pString =
new wxString(Character, nRepeat);
106 m_pString = String ?
new wxString(*String) :
new wxString;
191 if( i >= 0 && i < (
int)
Length() )
196 return(
SG_T(
'\0') );
206 return(
SG_T(
'\0') );
216 return(
SG_T(
'\0') );
275 wxString _Format(
Format); _Format.Replace(
"%s",
"%ls");
276 va_list argptr; va_start(argptr, _Format);
279 va_list argptr; va_start(argptr,
Format);
294 wxString _Format(
Format); _Format.Replace(
"%s",
"%ls");
295 va_list argptr; va_start(argptr, _Format);
298 va_list argptr; va_start(argptr,
Format);
311 wxString _Format(
Format); _Format.Replace(
"%s",
"%ls");
312 va_list argptr; va_start(argptr, _Format);
313 int Result =
m_pString->PrintfV(_Format, argptr);
315 va_list argptr; va_start(argptr,
Format);
328 wxString _Format(
Format); _Format.Replace(
"%s",
"%ls");
329 va_list argptr; va_start(argptr, _Format);
330 int Result =
m_pString->PrintfV(_Format, argptr);
332 va_list argptr; va_start(argptr,
Format);
534 return(
m_pString->IsSameAs(Character, bCase) );
539 return(
m_pString->IsSameAs(Character, bCase) );
573 for(
size_t i=0; i<
Length(); i++)
575 if( (n == 0 || bReplaceAll)
599 for(
size_t i=0; i<
Length(); i++)
643 return( (
int)(n -
m_pString->Length()) );
654 return( (
int)(n -
m_pString->Length()) );
665 return(
m_pString->Find(Character, fromEnd) );
670 return(
m_pString->Find(Character, fromEnd) );
771 int Value;
return(
asInt(Value) ? Value : 0 );
776 const wxChar *start =
m_pString->c_str(); wxChar *end;
778 int value = wxStrtol(start, &end, 10);
809 double Value;
return(
asDouble(Value) ? Value : 0. );
814 const wxChar *start =
m_pString->c_str(); wxChar *end;
816 double value = wxStrtod(start, &end);
881 const wxScopedCharBuffer Buffer =
m_pString->utf8_str();
883 String.
Set_Data(Buffer.data(), Buffer.length() + 1);
923 wxScopedCharBuffer Buffer;
934 default : Buffer =
m_pString->mb_str(wxConvAuto ());
break;
937 String.
Set_Data(Buffer.data(), Buffer.length() + 1);
977 #if wxCHECK_VERSION(3, 1, 0)
980 const wxScopedCharBuffer Buffer =
m_pString->ToAscii();
983 String.
Set_Data(Buffer.data(), Buffer.length() + 1);
1037 return(
Add(Strings) );
1043 for(
int i=0; i<nStrings; i++)
1071 for(
size_t i=0; i<Strings.
Get_Size(); i++)
1099 return(
Add(String) );
1104 for(
size_t i=
Get_Size()-1; i>Index; i--)
1127 for(
size_t i=Index+1; i<
Get_Size(); i++)
1140 while(
Del(Count) ) {}
1142 for(
size_t i=
Get_Size(); i<Count; i++)
1156 CSG_Index_Compare_Strings(
CSG_String **Values,
bool Ascending) : m_Values(Values), m_Ascending(Ascending) {}
1158 virtual int Compare (
const sLong _a,
const sLong _b)
1160 sLong a = m_Ascending ? _a : _b;
1161 sLong b = m_Ascending ? _b : _a;
1163 return( m_Values[a]->Cmp(*m_Values[b]) );
1233 CSG_String s; wxDateTime t; t.SetToCurrent();
1237 s += t.FormatISODate().wc_str(); s +=
"/";
1240 s += t.FormatISOTime().wc_str();
1255 int deg, min;
double sec;
char sig = Value < 0. ?
'-' :
'+';
1262 Value = fmod(Value, 360.);
1264 Value = 60. * (Value - deg);
1266 Value = 60. * (Value - min);
1275 double sig = 1., deg = 0., min = 0., sec = 0.;
1281 sig = -1.; deg = -deg;
1292 return( sig * (deg + min / 60. + sec / 3600.) );
1307 Value = fabs(Value);
1309 for(decimals=0; decimals<maxDecimals; decimals++)
1311 double Remainder = Value - floor(Value);
1313 if( Remainder == 0. )
1321 return( maxDecimals );
1334 for(
size_t i=0; i<String.
Length(); i++)
1371 if ( Precision == -99 )
1375 else if( Precision == -98 )
1379 else if( Precision == -97 )
1383 else if( Precision == 0 )
1385 s.
Printf(
"%d", (
int)Value);
1387 else if( Precision > 0 )
1389 s.
Printf(
"%.*f", Precision, Value);
1397 s.
Printf(
"%d", (
int)Value);
1399 else if( Decimals > Precision )
1405 s.
Printf(
"%.*f", Decimals, Value);
1450 {
"table",
"\n============\n",
"============\n" },
1451 {
"tr" ,
"" ,
"\n" },
1452 {
"th" ,
"" ,
"\t" },
1453 {
"td" ,
"" ,
"\t" },
1455 {
"b" ,
"[" ,
"]" },
1456 {
"i" ,
"'" ,
"'" },
1457 {
"code" ,
"`" ,
"`" },
1458 {
"br" ,
"\n" ,
"" },
1459 {
"p" ,
"" ,
"\n" },
1460 {
"hr" ,
"\n____________\n",
"\n" },
1461 {
"h1" ,
"\n############\n",
"\n" },
1462 {
"h2" ,
"\n============\n",
"\n" },
1463 {
"h3" ,
"\n------------\n",
"\n" },
1464 {
"h4" ,
"\n" ,
"\n" },
1465 {
"ol" ,
"\n" ,
"\n" },
1466 {
"ul" ,
"\n" ,
"\n" },
1467 {
"li" ,
"(-) " ,
"\n" },
1473 for(
int i=0, n; !Tags[i][0].
is_Empty(); i++)
1475 _Text.
Replace(
"<" + Tags[i][0] +
">", Tags[i][1]);
1477 while( (n = _Text.
Find(
"<" + Tags[i][0])) >= 0 )
1481 if( Tags[i][0].Cmp(
"a") == 0 && (n = Right.
BeforeFirst(
'>').
Find(
"href=\"")) >= 0 )
1485 if( !href.
is_Empty() && (n = Right.
Find(
"</a>")) >= 0 )
1491 _Text = Left +
"[" + text +
"](" + href +
")" + Right.
Right(Right.
Length() - n);
1498 _Text = Left + Tags[i][1] + Right.
AfterFirst(
'>');
1501 _Text.
Replace(
"</" + Tags[i][0] +
">", Tags[i][2]);
1517 m_pTokenizer =
new wxStringTokenizer();
1523 m_pTokenizer =
new wxStringTokenizer();
1531 delete(m_pTokenizer);
1537 return( m_pTokenizer->CountTokens() );
1543 return( m_pTokenizer->GetLastDelimiter() );
1549 wxString s(m_pTokenizer->GetNextToken());
1557 return( m_pTokenizer->GetPosition() );
1563 wxString s(m_pTokenizer->GetString());
1571 return( m_pTokenizer->HasMoreTokens() );
1577 wxStringTokenizerMode _Mode;
1581 default: _Mode = wxTOKEN_DEFAULT ;
break;
1589 m_pTokenizer->SetString(String.
c_str(), Delimiters.
c_str(), _Mode);
SAGA_API_DLL_EXPORT void * SG_Malloc(size_t size)
TSG_String_Tokenizer_Mode
@ SG_FILE_ENCODING_UTF16LE
@ SG_FILE_ENCODING_UTF16BE
@ SG_FILE_ENCODING_UTF32BE
@ SG_FILE_ENCODING_UTF32LE
CSG_String operator+(const char *A, const CSG_String &B)
CSG_String SG_Get_CurrentTimeStr(bool bWithDate)
double SG_Degree_To_Double(const CSG_String &String)
bool SG_is_Character_Numeric(int Character)
CSG_Strings SG_String_Tokenize(const CSG_String &String, const CSG_String &Delimiters, TSG_String_Tokenizer_Mode Mode)
int SG_Get_Significant_Decimals(double Value, int maxDecimals)
void SG_Flip_Decimal_Separators(CSG_String &String)
CSG_String SG_Double_To_Degree(double Value)
CSG_String SG_Get_String(double Value, int Precision)
CSG_String SG_HTML_Tag_Replacer(const CSG_String &Text)
size_t Get_Size(void) const
bool Set_Data(const char *Data, size_t Size, bool bShrink=true)
char * Get_Data(int Offset=0) const
size_t Get_Position(void) const
SG_Char Get_Last_Delimiter(void) const
size_t Get_Tokens_Count(void) const
CSG_String Get_Next_Token(void)
bool Has_More_Tokens(void) const
void Set_String(const CSG_String &String, const CSG_String &Delimiters=SG_DEFAULT_DELIMITERS, TSG_String_Tokenizer_Mode Mode=SG_TOKEN_DEFAULT)
~CSG_String_Tokenizer(void)
CSG_String Get_String(void) const
CSG_String_Tokenizer(void)
size_t Length(void) const
CSG_String AfterFirst(char Character) const
const char * b_str(void) const
CSG_String & Remove(size_t pos)
int CmpNoCase(const CSG_String &String) const
CSG_String AfterLast(char Character) const
int Cmp(const CSG_String &String) const
size_t Replace_Single_Char(const SG_Char Old, const CSG_String &New, bool bReplaceAll=true)
CSG_String & operator=(const CSG_String &String)
CSG_String BeforeFirst(char Character) const
void operator+=(const CSG_String &String)
virtual ~CSG_String(void)
void Set_Char(size_t i, char Character)
size_t Replace(const CSG_String &Old, const CSG_String &New, bool bReplaceAll=true)
std::string to_StdString(void) const
CSG_String operator+(const CSG_String &String) const
CSG_String BeforeLast(char Character) const
static CSG_String Format(const char *Format,...)
int Trim(bool fromRight=false)
CSG_String & Append(const CSG_String &String)
int Find(char Character, bool fromEnd=false) const
size_t to_MBChar(char **pString, int Encoding) const
bool is_Same_As(const CSG_String &String, bool bCase=true) const
SG_Char Get_Char(size_t i) const
SG_Char operator[](int i) const
CSG_String Right(size_t count) const
const SG_Char * c_str(void) const
bool to_ASCII(char **pString, char Replace='_') const
CSG_String & Make_Lower(void)
class wxString * m_pString
int Printf(const char *Format,...)
bool is_Empty(void) const
CSG_String Mid(size_t first, size_t count=0) const
bool Contains(const CSG_String &String) const
CSG_String Left(size_t count) const
static CSG_String from_UTF8(const char *String, size_t Length=0)
CSG_Buffer to_UTF8(void) const
bool is_Number(void) const
std::wstring to_StdWstring(void) const
CSG_String & Make_Upper(void)
double asDouble(void) const
bool Create(const class wxString *pString)
const wchar_t * w_str(void) const
CSG_String & Prepend(const CSG_String &String)
sLong asLongLong(void) const
bool Add(const CSG_Strings &Strings)
CSG_Array_Pointer m_Strings
bool Sort(bool Ascending=true)
bool Set_Count(int Count)
bool Create(const CSG_Strings &Strings)
size_t Get_Size(void) const
int Get_Count(void) const
virtual ~CSG_Strings(void)
bool Ins(const CSG_String &String, int Index)