前のページ次のページ上に戻るホーム BREW C++ ライブラリ & GUI フレームワーク & XML ミドルウェア : SophiaFramework 4.1
SFXWideString
WChar 型文字列を表すクラスです。
#include <SFXWideString.h.hpp>
class SFXWideString;
SFMTYPEDEFCLASS(SFXWideString)

協調図

SFXWideString クラスの協調図

解説

SFXAnsiString と SFXWideString

BREW には、シングルバイト文字またはマルチバイト文字を表す char 型と、 BREW 独自の 2 バイト文字を表す AECHAR 型があります。 SophiaFramewok では、これら 2 種類の文字型をそれぞれ AChar 型、WChar 型として定義しています。

文字列を表すクラスには、AChar 型の文字で構成される SFXAnsiString と、 WChar 型の文字で構成される SFXWideString の 2 種類があります。

文字列を空にする方法

文字列を空にする方法は 2 つあります。

ひとつは、空文字列を代入する、または パラメーターを "0" に設定して SFXWideString::SetLength 関数を呼び出す方法です。 もうひとつは、SFXWideString::Clear 関数を呼び出す方法です。

前者の方法では、ヒープは解放されません。ブロック アロケーションのサポートにより、文字列を作成するときにメモリを新たに確保することなく、このヒープ領域を利用できるので処理が速くなります。

後者の方法では、ヒープを解放します。解放したヒープは他の用途に利用できますが、その分、実行速度は遅くなります。

どちらを使うかは、実行速度とメモリ使用量のどちらを優先させるかで判断します。

例 502. 空文字列を代入する、または SFXWideString::SetLength 関数を呼び出す方法

SFXWideString str = "最も優れた BREW  C++ プログラミング環境";

str = "";
// または
str.SetLength(0);

// ヒープは解放されない

例 503. Clear 関数を呼び出す方法

SFXWideString str = "最も優れた BREW  C++ プログラミング環境";

str.Clear();

// ヒープは解放される

短い文字列を頻繁に処理するときは、SFXWideString::SetLength 関数を呼び出す方法が効率的です。

SFXWideString str;

str = "プログラミング環境";
...
str.SetLength(0);
...
str = "フレームワーク";
...
str.SetLength(0);
...
str = "ミドルウェア";
...

Attach 関数 と Detach 関数

SFXWideString::Attach 関数は、WChar 型文字列の動作と管理権限を SFXWideString クラスのインスタンスにデリゲート(委譲)します。 そのため、WChar 型文字列のメモリを解放する必要がなくなります。 SFXWideString::Detach 関数はその逆の操作を行います。

SFXWideString::Set 関数や代入演算子 ( = ) では、データはコピーがされますが、 SFXWideString::Attach 関数や SFXWideString::Detach 関数では、データはコピーされません。

数百 KB もの文字列をコピーするためのヒープが無いとき、或いは、パフォーマンス劣化の問題を回避するときに利用します。

デリゲートとは : オブジェクト指向プログラミングにおいて、あるオブジェクトの振る舞いを別のオブジェクトに肩代わりして振る舞ってもらうことです。 日本語では、「委譲」と訳されます。

SFXWideString str;
WCharPtr ptr;

// メモリを割り当て、WChar 型文字列にキャストする
ptr = static_cast<WCharPtr>(MemoryAllocate(10240)); 

...

// WChar 型文字列 ptr の動作と管理権限を SFXWideString クラスのインスタンス str にデリゲートする
str.Attach(ptr, 10240);
// 以降、WChar 型文字列 ptr を SFXWideString クラスのインスタンス str として操作できる

・・・

// 使用後、割り当てたメモリは自動的に解放される 
SFXWideString str;
WCharPtr ptr;
SInt32 length;

str = "BREW  C++ プログラミング環境";

...

// SFXWideString クラスのインスタンス str の動作と管理権限を WChar 型文字列 ptr にデリゲートする
ptr = str.Detach(&length);
// 以降、SFXWideString クラスのインスタンス を WChar 型文字列 ptr として操作する

...

// 使用後、WChar 型文字列 ptr のメモリを解放する必要がある
MemoryFree(ptr);

AttachSFXBuffer 関数 と DetachSFXBuffer 関数

SFXWideString と SFXBuffer のクラスのインスタンス間で動作と管理権限をデリゲート(委譲)するときに使います。

関連情報 : Attach 関数 と Detach 関数

参照

SFXAnsiString | SFXBuffer

メンバ

コンストラクタ/デストラクタ
SFXWideString( Void )
SFXWideString( SFXWideStringConstRef string )
SFXWideString( SFXAnsiStringConstRef string )
SFXWideString( WCharConstPtr string , SInt32 length = -1 )
SFXWideString( ACharConstPtr string , SInt32 length = -1 )
SFXWideString( WChar character )
SFXWideString( SFXBufferConstRef buffer )
SFXWideString( UInt16 threshold , UInt16 cluster )
SFXWideString クラスのコンストラクタです。
~SFXWideString( Void )
SFXWideString クラスのデストラクタです。
パブリック関数
SFCError Add( SFXWideStringConstRef string )
Add( WChar character )
Add( WCharConstPtr string , SInt32 length = -1 )
追加します。
SFXWideString AsLower( Void )
小文字に変換します。
SInt32 AsSInt32( SInt32 substitute = 0 )
SInt32 型に変換します。
UInt32 AsUInt32( UInt32 substitute = 0 )
UInt32 型に変換します。
SFXWideString AsUpper( Void )
大文字に変換します。
SFCError Attach( WCharPtr string , SInt32 length = -1 )
指定した WChar 型文字列の動作と管理権限を SFXWideString クラスのインスタンスにデリゲート (委譲) します。
SFCError AttachSFXBuffer( SFXBufferPtr buffer )
指定した SFXBuffer クラスのインスタンスの動作と管理権限を SFXWideString クラスのインスタンスにデリゲート(委譲) します。
Void Clear( Void )
空にします。
SInt32 Compare( SFXWideStringConstRef string , Bool sensitive = true )
Compare( WCharConstPtr string , Bool sensitive = true )
辞書順に比較します。
SFXWideString Concat( SFXWideStringConstRef string )
Concat( WChar character )
Concat( WCharConstPtr string , SInt32 length = -1 )
連結します。
SFCError Copy( SInt32 index , SFXWideStringConstRef string )
Copy( SInt32 index , WCharConstPtr string , SInt32 length = -1 )
上書きします。
WCharPtr Detach( SInt32Ptr length = null )
SFXWideString クラスのインスタンスの動作と管理権限を WChar 型文字列にデリゲート(委譲) します。
SFCError DetachSFXBuffer( SFXBufferPtr buffer )
SFXWideString クラスのインスタンスの動作と管理権限を SFXBuffer クラスのインスタンスにデリゲート(委譲) します。
static
SFXWideStringConstRef
EmptyInstance( Void )
空文字列を取得します。
Bool EndsWith( SFXWideStringConstRef string , Bool sensitive = true )
EndsWith( WChar character , Bool sensitive = true )
EndsWith( WCharConstPtr string , Bool sensitive = true )
指定した文字列で終わるか判定します。
Bool Equals( SFXWideStringConstRef string , Bool sensitive = true )
Equals( WCharConstPtr string , Bool sensitive = true )
等しいか判定します。
Void Fill( WChar character )
指定した文字で埋めます。
SInt32 FirstIndexOf( SFXWideStringConstRef string , SInt32 index = SINT32_MINIMUM , Bool sensitive = true )
FirstIndexOf( WChar character , SInt32 index = SINT32_MINIMUM , Bool sensitive = true )
FirstIndexOf( WCharConstPtr string , SInt32 index = SINT32_MINIMUM , Bool sensitive = true )
先頭から検索してインデックスを取得します。
static
SFXWideString
Format( va_ref< SFXWideStringConst > format , ... )
Format( ACharConstPtr format , ... )
Format( WCharConstPtr format , ... )
Format( va_ref< SFXAnsiStringConst > format , ... )
データを書式に従った文字列に設定し直します。
static
SFXWideString
FormatV( SFXWideStringConstRef format , va_list argument )
FormatV( ACharConstPtr format , va_list argument )
FormatV( WCharConstPtr format , va_list argument )
FormatV( SFXAnsiStringConstRef format , va_list argument )
可変個引数リストを書式に従った文字列に設定し直します。
WCharPtr GetBuffer( Void )
文字列の内部バッファーへのポインターを取得します。
WCharConstPtr GetBuffer( Void )
文字列の内部バッファーへのポインターを取得します。
WCharConstPtr GetCString( Void )
文字列の内部バッファーへの const ポインターを取得します。(内部バッファーの内容を変更できません)
WChar GetChar( SInt32 index )
指定した位置の文字を取得します。
UInt16 GetCluster( Void )
内部バッファ メモリのクラスタ サイズを取得します。
SInt32 GetLength( Void )
文字数を取得します。
SInt32 GetLengthCString( Void )
先頭の null 文字までの文字数を取得します。
UInt16 GetThreshold( Void )
内部バッファ サイズの最小値を取得します。
SFXWideString Insert( SInt32 index , SFXWideStringConstRef string )
Insert( SInt32 index , WChar character )
Insert( SInt32 index , WCharConstPtr string , SInt32 length = -1 )
挿入します。
Bool IsAlpha( Void )
すべて英文字か判定します。
Bool IsAlphaDigit( Void )
すべて英数字か判定します。
Bool IsAscii( Void )
すべて ASCII 文字か判定します。
Bool IsControl( Void )
すべて制御文字か判定します。
Bool IsDigit( Void )
すべて数字か判定します。
Bool IsEmpty( Void )
長さが 0 か判定します。
Bool IsEmptyCString( Void )
先頭の文字が null 文字か判定します。
Bool IsGraph( Void )
すべて図形文字か判定します。
Bool IsHexDigit( Void )
すべて 16 進数で使う文字か判定します。
Bool IsLower( Void )
すべて小文字か判定します。
Bool IsNull( Void )
すべて null か判定します。
Bool IsPrint( Void )
すべて印字文字か判定します。
Bool IsPunct( Void )
すべて印字可能文字か判定します。( 空白文字、英数字は含みません )
Bool IsSpace( Void )
すべて空白文字、または改行文字か判定します。
Bool IsUpper( Void )
すべて大文字か判定します。
SInt32 LastIndexOf( SFXWideStringConstRef string , SInt32 index = SINT32_MAXIMUM , Bool sensitive = true )
LastIndexOf( WChar character , SInt32 index = SINT32_MAXIMUM , Bool sensitive = true )
LastIndexOf( WCharConstPtr string , SInt32 index = SINT32_MAXIMUM , Bool sensitive = true )
末尾から検索してインデックスを取得します。
SFCError Mul( SInt32 repeat )
指定した回数繰り返します。
SFXWideString Remove( SInt32 begin , SInt32 end )
指定した範囲の文字列を消去します。
SFXWideString Replace( SFXWideStringConstRef fstring , SFXWideStringConstRef tstring , Bool sensitive = true )
Replace( WChar fcharacter , WCharConstPtr tstring , SInt32 tlength , Bool sensitive = true )
Replace( WChar fcharacter , WCharConstPtr tstring , Bool sensitive = true )
Replace( WCharConstPtr fstring , SInt32 flength , WChar tcharacter , Bool sensitive = true )
Replace( WCharConstPtr fstring , WChar tcharacter , Bool sensitive = true )
Replace( WChar fcharacter , WChar tcharacter , Bool sensitive = true )
Replace( WChar fcharacter , SFXWideStringConstRef tstring , Bool sensitive = true )
Replace( SFXWideStringConstRef fstring , WChar tcharacter , Bool sensitive = true )
Replace( WCharConstPtr fstring , SInt32 flength , WCharConstPtr tstring , SInt32 tlength , Bool sensitive = true )
Replace( WCharConstPtr fstring , WCharConstPtr tstring , Bool sensitive = true )
Replace( WCharConstPtr fstring , SInt32 flength , SFXWideStringConstRef tstring , Bool sensitive = true )
Replace( WCharConstPtr fstring , SFXWideStringConstRef tstring , Bool sensitive = true )
Replace( SFXWideStringConstRef fstring , WCharConstPtr tstring , SInt32 tlength , Bool sensitive = true )
Replace( SFXWideStringConstRef fstring , WCharConstPtr tstring , Bool sensitive = true )
置換します。
SFCError Set( SFXWideStringConstRef string )
Set( SFXBufferConstRef buffer )
Set( WChar character )
Set( ACharConstPtr string , SInt32 length = -1 )
Set( WCharConstPtr string , SInt32 length = -1 )
Set( SFXAnsiStringConstRef string )
設定します。
SFCError SetChar( SInt32 index , WChar character )
指定した位置の文字を設定します。
Void SetCluster( UInt16 size )
内部バッファ メモリのクラスタ サイズを設定します。
SFCError SetLength( SInt32 length )
文字数を設定します。
Void SetThreshold( UInt16 size )
内部バッファ サイズの最小値を設定します。
Bool StartsWith( SFXWideStringConstRef string , Bool sensitive = true )
StartsWith( WChar character , Bool sensitive = true )
StartsWith( WCharConstPtr string , Bool sensitive = true )
指定した文字列で始まるか判定します。
SFCError Sub( SFXWideStringConstRef string )
Sub( WChar character )
Sub( WCharConstPtr string , SInt32 length = -1 )
末尾から文字列を削除します。
SFXWideString Substring( SInt32 begin , SInt32 end )
部分文字列を取得します。
Void ToLower( Void )
小文字に変換します。
Void ToUpper( Void )
大文字に変換します。
SFXWideString Trim( SFXWideStringConstRef string , Bool sensitive = true )
Trim( Void )
Trim( WChar character , Bool sensitive = true )
Trim( WCharConstPtr string , Bool sensitive = true )
先頭と末尾から空白や任意の文字を削除します。
SFXWideString TrimLeft( SFXWideStringConstRef string , Bool sensitive = true )
TrimLeft( Void )
TrimLeft( AChar character , Bool sensitive = true )
TrimLeft( ACharConstPtr string , Bool sensitive = true )
先頭から空白や任意の文字を削除します。
SFXWideString TrimRight( SFXWideStringConstRef string , Bool sensitive = true )
TrimRight( Void )
TrimRight( AChar character , Bool sensitive = true )
TrimRight( ACharConstPtr string , Bool sensitive = true )
末尾から空白や任意の文字を削除します。
SFXWideString Truncate( Void )
先頭の null 文字までの文字列を取得します。
SFXWideStringRef operator*=( SInt32 repeat )
指定した回数繰り返します。
SFXWideStringRef operator+=( SFXWideStringConstRef string )
operator+=( WChar character )
operator+=( WCharConstPtr string )
追加します。
SFXWideStringRef operator-=( SFXWideStringConstRef string )
operator-=( WChar character )
operator-=( WCharConstPtr string )
末尾から文字列を削除します。
SFXWideStringRef operator<<( SFXWideStringRef left , SFXWideStringConstRef right )
operator<<( SFXWideStringRef left , WChar right )
operator<<( SFXWideStringRef left , ACharConstPtr right )
operator<<( SFXWideStringRef left , WCharConstPtr right )
operator<<( SFXWideStringRef left , SFXAnsiStringConstRef right )
追加します。
SFXWideStringRef operator=( SFXWideStringConstRef string )
operator=( ACharConstPtr string )
operator=( WCharConstPtr string )
operator=( SFXAnsiStringConstRef string )
代入します。
WCharRef operator[]( SInt32 index )
指定した位置の文字を取得します。
WCharConstRef operator[]( SInt32 index )
指定した位置の文字を取得します。
Bool operator==( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator==( ACharConstPtr left , SFXWideStringConstRef right )
operator==( WCharConstPtr left , SFXWideStringConstRef right )
operator==( SFXWideStringConstRef left , ACharConstPtr right )
operator==( SFXWideStringConstRef left , WCharConstPtr right )
operator==( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
== の関係を判定します。
Bool operator>=( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator>=( ACharConstPtr left , SFXWideStringConstRef right )
operator>=( WCharConstPtr left , SFXWideStringConstRef right )
operator>=( SFXWideStringConstRef left , ACharConstPtr right )
operator>=( SFXWideStringConstRef left , WCharConstPtr right )
operator>=( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
>= の関係を判定します。
Bool operator>( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator>( ACharConstPtr left , SFXWideStringConstRef right )
operator>( WCharConstPtr left , SFXWideStringConstRef right )
operator>( SFXWideStringConstRef left , ACharConstPtr right )
operator>( SFXWideStringConstRef left , WCharConstPtr right )
operator>( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
> の関係を判定します。
Bool operator<=( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator<=( ACharConstPtr left , SFXWideStringConstRef right )
operator<=( WCharConstPtr left , SFXWideStringConstRef right )
operator<=( SFXWideStringConstRef left , ACharConstPtr right )
operator<=( SFXWideStringConstRef left , WCharConstPtr right )
operator<=( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
<= の関係を判定します。
Bool operator<( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator<( ACharConstPtr left , SFXWideStringConstRef right )
operator<( WCharConstPtr left , SFXWideStringConstRef right )
operator<( SFXWideStringConstRef left , ACharConstPtr right )
operator<( SFXWideStringConstRef left , WCharConstPtr right )
operator<( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
< の関係を判定します。
SFXWideString operator-( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator-( WChar left , SFXWideStringConstRef right )
operator-( SFXWideStringConstRef left , WChar right )
operator-( ACharConstPtr left , SFXWideStringConstRef right )
operator-( WCharConstPtr left , SFXWideStringConstRef right )
operator-( SFXWideStringConstRef left , ACharConstPtr right )
operator-( SFXWideStringConstRef left , WCharConstPtr right )
operator-( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
末尾から文字列を削除します。
SFXWideString operator*( SFXWideStringConstRef left , SInt32 right )
指定した回数繰り返します。
Bool operator!=( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator!=( ACharConstPtr left , SFXWideStringConstRef right )
operator!=( WCharConstPtr left , SFXWideStringConstRef right )
operator!=( SFXWideStringConstRef left , ACharConstPtr right )
operator!=( SFXWideStringConstRef left , WCharConstPtr right )
operator!=( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
!= の関係を判定します。
SFXWideString operator+( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator+( WChar left , SFXWideStringConstRef right )
operator+( SFXWideStringConstRef left , WChar right )
operator+( ACharConstPtr left , SFXWideStringConstRef right )
operator+( WCharConstPtr left , SFXWideStringConstRef right )
operator+( SFXWideStringConstRef left , ACharConstPtr right )
operator+( SFXWideStringConstRef left , WCharConstPtr right )
operator+( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
追加します。
DefaultEnum
内部で使うヒープ サイズの閾値とクラスタ サイズの既定値を表します。
グローバル関数
Bool operator==( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator==( ACharConstPtr left , SFXWideStringConstRef right )
operator==( WCharConstPtr left , SFXWideStringConstRef right )
operator==( SFXWideStringConstRef left , ACharConstPtr right )
operator==( SFXWideStringConstRef left , WCharConstPtr right )
operator==( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
== の関係を判定します。
Bool operator>=( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator>=( ACharConstPtr left , SFXWideStringConstRef right )
operator>=( WCharConstPtr left , SFXWideStringConstRef right )
operator>=( SFXWideStringConstRef left , ACharConstPtr right )
operator>=( SFXWideStringConstRef left , WCharConstPtr right )
operator>=( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
>= の関係を判定します。
Bool operator>( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator>( ACharConstPtr left , SFXWideStringConstRef right )
operator>( WCharConstPtr left , SFXWideStringConstRef right )
operator>( SFXWideStringConstRef left , ACharConstPtr right )
operator>( SFXWideStringConstRef left , WCharConstPtr right )
operator>( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
> の関係を判定します。
Bool operator<=( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator<=( ACharConstPtr left , SFXWideStringConstRef right )
operator<=( WCharConstPtr left , SFXWideStringConstRef right )
operator<=( SFXWideStringConstRef left , ACharConstPtr right )
operator<=( SFXWideStringConstRef left , WCharConstPtr right )
operator<=( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
<= の関係を判定します。
Bool operator<( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator<( ACharConstPtr left , SFXWideStringConstRef right )
operator<( WCharConstPtr left , SFXWideStringConstRef right )
operator<( SFXWideStringConstRef left , ACharConstPtr right )
operator<( SFXWideStringConstRef left , WCharConstPtr right )
operator<( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
< の関係を判定します。
SFXWideString operator-( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator-( WChar left , SFXWideStringConstRef right )
operator-( SFXWideStringConstRef left , WChar right )
operator-( ACharConstPtr left , SFXWideStringConstRef right )
operator-( WCharConstPtr left , SFXWideStringConstRef right )
operator-( SFXWideStringConstRef left , ACharConstPtr right )
operator-( SFXWideStringConstRef left , WCharConstPtr right )
operator-( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
末尾から文字列を削除します。
SFXWideString operator*( SFXWideStringConstRef left , SInt32 right )
指定した回数繰り返します。
Bool operator!=( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator!=( ACharConstPtr left , SFXWideStringConstRef right )
operator!=( WCharConstPtr left , SFXWideStringConstRef right )
operator!=( SFXWideStringConstRef left , ACharConstPtr right )
operator!=( SFXWideStringConstRef left , WCharConstPtr right )
operator!=( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
!= の関係を判定します。
SFXWideString operator+( SFXWideStringConstRef left , SFXWideStringConstRef right )
operator+( WChar left , SFXWideStringConstRef right )
operator+( SFXWideStringConstRef left , WChar right )
operator+( ACharConstPtr left , SFXWideStringConstRef right )
operator+( WCharConstPtr left , SFXWideStringConstRef right )
operator+( SFXWideStringConstRef left , ACharConstPtr right )
operator+( SFXWideStringConstRef left , WCharConstPtr right )
operator+( SFXWideStringConstRef left , SFXAnsiStringConstRef right )
追加します。

SFXWideString::SFXWideString
SFXWideString クラスのコンストラクタです。
[ public, explicit ]
SFXWideString(Void);
[ public ]
SFXWideString(
    SFXWideStringConstRef string   // コピー元の文字列
);
[ public ]
SFXWideString(
    SFXAnsiStringConstRef string   // コピー元の文字列
);
[ public ]
SFXWideString(
    WCharConstPtr string   // コピー元の WChar ポインター
    SInt32 length = -1     // 文字列の文字数
);
[ public ]
SFXWideString(
    ACharConstPtr string   // コピー元の AChar ポインター
    SInt32 length = -1     // 文字列の文字数
);
[ public, explicit ]
SFXWideString(
    WChar character   // WChar 文字
);
[ public, explicit ]
SFXWideString(
    SFXBufferConstRef buffer   // コピー元のバッファ
);
[ public, explicit ]
SFXWideString(
    UInt16 threshold   // バッファサイズの最小値
    UInt16 cluster     // クラスタサイズ
);

解説

SFXWideString クラスのコンストラクタに SFXWideString クラス、または SFXAnsiString クラスを指定すると、 その文字列をコピーします。

WChar や AChar のポインターを指定すると、null 終端文字列と解釈してコピーします。

長さを指定すると null を含んだバイナリ文字列を処理できます。

WChar を指定すると、1 文字だけを作成します。

参照

SFXWideString::Set | SFXWideString::operator=


SFXWideString::~SFXWideString
SFXWideString クラスのデストラクタです。
[ public ]
~SFXWideString(Void);

解説

内部の文字列バッファは解放されます。


SFXWideString::Add
追加します。
[ public ]
SFCError Add(
    SFXWideStringConstRef string   // 追加する文字列
);
[ public ]
SFCError Add(
    WCharConstPtr string   // 追加する文字列
    SInt32 length = -1     // 文字列の文字数
);
[ public ]
SFCError Add(
    WChar character   // 追加する文字
);

戻り値

  • 成功したとき : SFERR_NO_ERROR
  • 失敗したとき : SFERR_FAILED
  • メモリ不足のとき : SFERR_NO_MEMORY

解説

SFXWideString::Add 関数は文字列に影響を及ぼします。 変換元の文字列を保持しておく場合は、SFXWideString::Concat 関数を使います。

参照

SFXWideString::Concat | SFXWideString::Sub | SFXWideString::Mul | SFXWideString::operator<< | operator+ | SFXWideString::operator+=


SFXWideString::AsLower
小文字に変換します。
[ public, const ]
SFXWideString AsLower(Void);

解説

SFXWideString::AsLower 関数を呼び出しても、元の文字列は変化しません。

参照

SFXWideString::AsUpper | SFXWideString::ToLower


SFXWideString::AsSInt32
SInt32 型に変換します。
[ public, const ]
SInt32 AsSInt32(
    SInt32 substitute = 0   // 変換失敗時の値
);

解説

変換できなかった場合は substitute に指定した値を返します。

参照

SFXWideString::AsUInt32


SFXWideString::AsUInt32
UInt32 型に変換します。
[ public, const ]
UInt32 AsUInt32(
    UInt32 substitute = 0   // 変換失敗時の値
);

解説

変換できなかった場合は substitute に指定した値を返します。

参照

SFXWideString::AsSInt32


SFXWideString::AsUpper
大文字に変換します。
[ public, const ]
SFXWideString AsUpper(Void);

解説

SFXWideString::AsUpper 関数を呼び出しても、元の文字列は変化しません。

参照

SFXWideString::AsLower | SFXWideString::ToUpper


SFXWideString::Attach
指定した WChar 型文字列の動作と管理権限を SFXWideString クラスのインスタンスにデリゲート (委譲) します。
[ public ]
SFCError Attach(
    WCharPtr string      // SFXWideString で管理する文字列
    SInt32 length = -1   // 文字列の文字数
);

戻り値

  • 成功したとき : SFERR_NO_ERROR
  • 引数が不正なとき : SFERR_INVALID_PARAM

解説

WChar 型文字列はコピーされないので、SFXWideString::Set 関数よりも効率的で、大容量の文字列データ処理時のパフォーマンス劣化やメモリ不足の問題を回避します。

WChar 型文字列に割り当てられたメモリは、SFXWideString クラスのインスタンスが解放されると自動的に解放されます。 WChar 型文字列に割り当てられたメモリを明示的に解放するには、SFXWideString::Detach 関数を呼び出す必要があります。

使用例

  
SFXWideString str;
WCharPtr ptr;

// メモリを割り当て、WChar 型文字列にキャストする
ptr = static_cast<WCharPtr>(MemoryAllocate(10240)); 

...

// WChar 型文字列 ptr の動作と管理権限を SFXWideString クラスのインスタンス str にデリゲートする
str.Attach(ptr, 10240);
// 以降、WChar 型文字列 ptr を SFXWideString クラスのインスタンス str として操作できる

・・・

// 使用後、割り当てたメモリは自動的に解放される 

参照

SFXWideString::Detach


SFXWideString::AttachSFXBuffer
指定した SFXBuffer クラスのインスタンスの動作と管理権限を SFXWideString クラスのインスタンスにデリゲート(委譲) します。
[ public ]
SFCError AttachSFXBuffer(
    SFXBufferPtr buffer   // 使用するバッファ
);

戻り値

  • 成功したとき : SFERR_NO_ERROR
  • SFXBuffer のポインターが null のとき、または引数が不正なとき : SFERR_INVALID_PARAM

解説

SFXBuffer クラスのインスタンスのデータはコピーされないので、SFXWideString::Set 関数よりも効率的で、大容量の文字列データ処理時のパフォーマンス劣化やメモリ不足の問題を回避できます。

SFXBuffer クラスのインスタンスは、SFXWideString クラスのインスタンスが解放されると自動的に解放されます。 SFXBuffer クラスのインスタンスを明示的に解放するには、SFXWideString::DetachSFXBuffer 関数を呼び出す必要があります。

使用例

SFXWideString str;
SFXBuffer buffer;

// SFXBuffer クラスのインスタンス buffer にメモリを割り当てる
buffer.SetSize(10240); 

...

// SFXBuffer クラスのインスタンス buffer の動作と管理権限を SFWideString クラスのインスタンス str にデリゲートする
str.AttachSFXBuffer(&buffer);
// 以降、SFXBuffer クラスのインスタンス buffer 型文字列 ptr を SFXWideString クラスのインスタンス str として操作できる

・・・

// 使用後、割り当てたメモリは自動的に解放される 

参照

SFXWideString::Attach | SFXWideString::Detach | SFXWideString::DetachSFXBuffer


SFXWideString::Clear
空にします。
[ public ]
Void Clear(Void);

解説

ヒープを解放します。


SFXWideString::Compare
辞書順に比較します。
[ public, const ]
SInt32 Compare(
    SFXWideStringConstRef string   // 比較する文字列
    Bool sensitive = true          // 大小文字を区別するか
);
[ public, const ]
SInt32 Compare(
    WCharConstPtr string    // 比較する文字列
    Bool sensitive = true   // 大小文字を区別するか
);

戻り値

  • string より小さいとき : 負の値
  • string と等しいとき : 0
  • string より大きいとき : 正の値

参照

SFXWideString::Equals | operator== | operator!=


SFXWideString::Concat
連結します。
[ public, const ]
SFXWideString Concat(
    SFXWideStringConstRef string   // 連結する文字列
);
[ public, const ]
SFXWideString Concat(
    WCharConstPtr string   // 連結する文字列
    SInt32 length = -1     // 文字列の文字数
);
[ public, const ]
SFXWideString Concat(
    WChar character   // 連結する文字
);

戻り値

連結後の文字列を返します。

解説

SFXWideString::Concat 関数は現在の文字列の最後に、指定した文字列を連結して返します。 元の文字列は変更されません。

参照

SFXWideString::Add | operator+ | SFXWideString::operator+=


SFXWideString::Copy
上書きします。
[ public ]
SFCError Copy(
    SInt32 index                   // 上書き開始位置
    SFXWideStringConstRef string   // コピーする文字列
);
[ public ]
SFCError Copy(
    SInt32 index           // 上書き開始位置
    WCharConstPtr string   // コピーする文字列
    SInt32 length = -1     // 文字列の長さ
);

戻り値

  • 成功したとき : SFERR_NO_ERROR
  • 文字列の終端を越えるとき : SFERR_INVALID_PARAM

解説

上書きする文字列が元の文字列の終端を越える場合は SFERR_INVALID_PARAM を返し、コピーは行われません。


SFXWideString::Detach
SFXWideString クラスのインスタンスの動作と管理権限を WChar 型文字列にデリゲート(委譲) します。
[ public ]
WCharPtr Detach(
    SInt32Ptr length = null   // 持っていた文字列の文字数を格納するためのポインター
);

戻り値

SFXWideString クラスが持っている WChar 型文字列を返します。

解説

SFXWideString クラスのインスタンスの文字列はコピーされないので、SFXWideString::GetChar 関数よりも効率的で、大容量の文字列データ処理時のパフォーマンス劣化やメモリ不足の問題を回避できます。

使用例

SFXWideString str;
WCharPtr ptr;
SInt32 length;

str = "BREW  C++ プログラミング環境";

...

// SFXWideString クラスのインスタンス str の動作と管理権限を WChar 型文字列 ptr にデリゲートする
ptr = str.Detach(&length);
// 以降、SFXWideString クラスのインスタンス を WChar 型文字列 ptr として操作する

...

// 使用後、WChar 型文字列 ptr のメモリを解放する必要がある
MemoryFree(ptr);

参照

SFXWideString::Attach


SFXWideString::DetachSFXBuffer
SFXWideString クラスのインスタンスの動作と管理権限を SFXBuffer クラスのインスタンスにデリゲート(委譲) します。
[ public ]
SFCError DetachSFXBuffer(
    SFXBufferPtr buffer   // 文字列のデータが代入される SFXBuffer のポインター
);

戻り値

  • 成功したとき : SFERR_NO_ERROR
  • SFXBuffer のポインターが null のとき、または引数が不正なとき : SFERR_INVALID_PARAM

解説

SFXWideString クラスのインスタンスの文字列はコピーされないので、大容量の文字列データ処理時のパフォーマンス劣化やメモリ不足の問題を回避できます。

使用例

SFXWideString str;
SFXBuffer buffer;

str = "BREW  C++ プログラミング環境";

...

// SFXWideString クラスのインスタンス str の動作と管理権限を SFXBuffer クラスのインスタンス buffer にデリゲートする
str.DetachSFXBuffer(&buffer);  
// 以降、SFXWideString クラスのインスタンス str を SFXBuffer クラスのインスタンス buffer として操作する

・・・

// 使用後、SFXBuffer クラスのインスタンス buffer は自動的に解放される

参照

SFXWideString::Attach | SFXWideString::AttachSFXBuffer | SFXWideString::Detach


SFXWideString::EmptyInstance
空文字列を取得します。
[ public, static ]
SFXWideStringConstRef EmptyInstance(Void);

解説

関数の戻り値として空文字列のインスタンスへの参照を返すときに使います。


SFXWideString::EndsWith
指定した文字列で終わるか判定します。
[ public, const ]
Bool EndsWith(
    SFXWideStringConstRef string   // 調べる文字列
    Bool sensitive = true          // 大小文字を区別するか
);
[ public, const ]
Bool EndsWith(
    WCharConstPtr string    // 調べる文字列
    Bool sensitive = true   // 大小文字を区別するか
);
[ public, const ]
Bool EndsWith(
    WChar character         // 調べる文字
    Bool sensitive = true   // 大小文字を区別するか
);

戻り値

  • 指定した文字列で終わるとき : true
  • 指定した文字列で終わらないとき : false

参照

SFXWideString::StartsWith


SFXWideString::Equals
等しいか判定します。
[ public, const ]
Bool Equals(
    SFXWideStringConstRef string   // 比較対象の文字列
    Bool sensitive = true          // 大小文字を区別するか
);
[ public, const ]
Bool Equals(
    WCharConstPtr string    // 比較対象の文字列
    Bool sensitive = true   // 大小文字を区別するか
);

戻り値

  • 等しいとき : true
  • 異なるとき : false

参照

SFXWideString::Compare | operator== | operator!=


SFXWideString::Fill
指定した文字で埋めます。
[ public ]
Void Fill(
    WChar character   // 文字
);

SFXWideString::FirstIndexOf
先頭から検索してインデックスを取得します。
[ public, const ]
SInt32 FirstIndexOf(
    SFXWideStringConstRef string    // 検索する文字列
    SInt32 index = SINT32_MINIMUM   // 検索開始位置
    Bool sensitive = true           // 大小文字を区別するか
);
[ public, const ]
SInt32 FirstIndexOf(
    WCharConstPtr string            // 検索する文字列
    SInt32 index = SINT32_MINIMUM   // 検索開始位置
    Bool sensitive = true           // 大小文字を区別するか
);
[ public, const ]
SInt32 FirstIndexOf(
    WChar character                 // 検索する文字
    SInt32 index = SINT32_MINIMUM   // 検索開始位置
    Bool sensitive = true           // 大小文字を区別するか
);

戻り値

  • 成功したとき : 見つかった位置のインデックス
  • 失敗したとき : -1

解説

文字列を先頭から末尾に向かって検索し、最初に見つかった位置のインデックスを取得します。

検索開始位置を指定することで、先頭以外の位置から検索できます。

参照

SFXWideString::LastIndexOf


SFXWideString::Format
データを書式に従った文字列に設定し直します。
[ public, static ]
SFXWideString Format(
    va_ref< SFXWideStringConst > format   // 書式を表す文字列
    ...                                   // データ
);
[ public, static ]
SFXWideString Format(
    va_ref< SFXAnsiStringConst > format   // 書式を表す文字列
    ...                                   // データ
);
[ public, static ]
SFXWideString Format(
    WCharConstPtr format   // 書式を表す文字列
    ...                    // データ
);
[ public, static ]
SFXWideString Format(
    ACharConstPtr format   // 書式を表す文字列
    ...                    // データ
);

解説

書式は C 言語の printf 関数とほぼ同じですが、浮動小数点数の書式は使えません。

使用例

SIntN year = 2003;
SIntN month = 8;
SFXWideString str = SFXWideString::Format("%d年%d月", year, month);

参照

BREW API VSNPRINTF


SFXWideString::FormatV
可変個引数リストを書式に従った文字列に設定し直します。
[ public, static ]
SFXWideString FormatV(
    SFXWideStringConstRef format   // 書式を表す文字列
    va_list argument               // 可変個引数リスト
);
[ public, static ]
SFXWideString FormatV(
    SFXAnsiStringConstRef format   // 書式を表す文字列
    va_list argument               // 可変個引数リスト
);
[ public, static ]
SFXWideString FormatV(
    WCharConstPtr format   // 書式を表す文字列
    va_list argument       // 可変個引数リスト
);
[ public, static ]
SFXWideString FormatV(
    ACharConstPtr format   // 書式を表す文字列
    va_list argument       // 可変個引数リスト
);

解説

書式は C 言語の printf 関数とほぼ同じですが、浮動小数点数の書式は使えません。

使用例

SFXWideString MyClass::variableArgument(SInt32 arg_num , ...) 
{
    va_list argument;

    va_start(argument, arg_num);
    
    SFXWideString str = SFXAnsiString::FormatV("%d年%d月%d日%d時%d分%d秒、天気は%sです。", argument);
    
    va_end(argument);
   
    return str;

}

SFXWideString str = variableArgument(7, 2007, 7, 17, 17, 37, 50,"雨");
// str = " 2007年7月17日17時37分50秒、天気は雨です。" 

参照

BREW API VSNPRINTF


SFXWideString::GetBuffer
文字列の内部バッファーへのポインターを取得します。
[ public ]
WCharPtr GetBuffer(Void);
[ public, const ]
WCharConstPtr GetBuffer(Void);

解説

SFXWideString::GetBuffer 関数は SFXWideString::GetLength 関数で得られる長さを超えてアクセスできません。

SFXWideString::GetBuffer 関数は文字列が空のとき null を返します。null ポインターを使って読み書きすることはできません。

そのため、SFXWideString::GetBuffer 関数を使用するときは、戻り値が null でないかを確認する必要があります。

参照

SFXWideString::GetChar | SFXWideString::SetChar | SFXWideString::GetLength | SFXWideString::SetLength | SFXWideString::GetCString


SFXWideString::GetCString
文字列の内部バッファーへの const ポインターを取得します。(内部バッファーの内容を変更できません)
[ public, const ]
WCharConstPtr GetCString(Void);

解説

SFXWideString::GetCString 関数は、文字列の内部バッファを WCharConstPtr 型( Const 型 )で返します。 そのため、このポインターを使って内部バッファへの書き込みはできません。

[Note] 注意
内部バッファへ書き込むには SFXWideString::GetBuffer 関数を