WritableString (クラス)
public abstract WritableString {inherits StringInterface}
パッケージ: CURL.LANGUAGE.STRINGS
直接継承しているサブクラス: StringBuf

読み書き可能文字列に対する抽象クラス。

説明

WritableString は、Curl における書き込み可能文字列クラスに対するインターフェイスです。つまり、WritableString は、Curl におけるほどんどの書き込み可能文字列クラスの基礎となるアクセッサとメソッドを備えています。

WritableString は抽象クラスなので、インスタンス化することはできません。文字列オブジェクトを作成するには、WritableString から継承される文字列クラスのいずれかをインスタンス化します。

Curl における文字列の詳細については、『Curl 開発者ガイド』の「文字列」の章を参照してください。

注意事項

以下に、Curl の文字列クラスの階層を示します。
StringInterface
SubString
ReadOnlyString
String
WritableString
StringBuf

プロパティ
efficient-size:selfefficient-size を取得または設定します。
アクセサ public inline WritableString.efficient-size:int
セッター public inline WritableString.efficient-size:int
プロパティ 継承 StringInterface: empty?, for-loop-count, size

メソッド
append:文字を self の末尾に追加します。
public {WritableString.append c:char}:void
clear:self をクリアします。
public {WritableString.clear}:void
concat:StringInterfaceself に連結します。
public {WritableString.concat str:StringInterface}:void
insert:文字を self に挿入します。
public abstract {WritableString.insert c:char, index:int}:void
remove:指定された文字を self から削除します。
public abstract {WritableString.remove
index:int,
length:int = 1,
error-if-missing?:bool = true
}:void
replace:old の各オカレンスを new に置換します。
public {WritableString.replace
old:StringInterface,
new:StringInterface,
starting-index:int = 0
}:void
reverse:self 内の文字の順序を逆にします。
public {WritableString.reverse}:void
set:self 内の文字を置換します。
public abstract {WritableString.set index:int, c:char}:void
set-contents:self の内容を別の文字列の内容に置換します。
public {WritableString.set-contents str:StringInterface}:void
splice:StringInterfaceself に挿入します。
public {WritableString.splice str:StringInterface, index:int}:void
to-lower:self 内の文字を小文字に変更します。
public {WritableString.to-lower}:void
to-upper:self 内の文字を大文字に変更します。
public {WritableString.to-upper}:void
trim:self の先頭および末尾の文字を削除します。
public {WritableString.trim
trim-chars:CharClass = CharClass.whitespace-chars
}:void
trim-left:self の先頭の文字を削除します。
public {WritableString.trim-left
trim-chars:CharClass = CharClass.whitespace-chars
}:void
trim-right:self の末尾の文字を削除します。
public {WritableString.trim-right
trim-chars:CharClass = CharClass.whitespace-chars
}:void
メソッド 継承 StringInterface: clone, compare, equal?, find, find-char-class, find-string, get, prefix?, replace-clone, split, substr, suffix?, tail, to-double, to-InputStream, to-int, to-int64, to-lower-clone, to-String, to-upper-clone, trim-clone, trim-left-clone, trim-right-clone
メソッド 継承 Object: object-describe, object-describe-for-debugging, object-serialize




プロパティ詳細
efficient-size (アクセサ)
アクセサ public inline WritableString.efficient-size:int
セッター public inline WritableString.efficient-size:int

selfefficient-size を取得または設定します。

説明

efficient-size は、WritableString またはサブクラスを拡張可能であり、かつ処理効率を維持できる上限サイズです。このアクセッサは実装ごとに定義されますが、一般に下位のデータ構造のサイズを反映します。割り当てサイズを超えて拡張する場合、下位のデータ構造を新しく割り当て、古いデータ構造からデータをコピーする必要があります。ただし、この処理は 非効率 であると見なされます。
requested-size: requested-size はシステムによって評価され、場合によっては変更されます。変更後の efficient-size を取得するには、ゲッターを使います。変更後の efficient-size は必ず requested-size 以上の大きさになります。

注意事項

efficient-size アクセッサの既定の実装はセッターを無視します。また、ゲッターは、すべてのサイズ変更処理が同程度に効率的であることを示す max-int を返します。





メソッド詳細
append (メソッド)
public {WritableString.append c:char}:void

文字を self の末尾に追加します。

c: 追加する文字。

説明

文字 cself の末尾に追加します。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Append an exclamation mark (!).
    {sb.append '!'}

    || Display the resulting StringBuf.
    {value sb}
}


clear (メソッド)
public {WritableString.clear}:void

self をクリアします。

説明

self の内容を空の文字列に置き換えます。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Clear the StringBuf.
    {sb.clear}

    || Check if the StringBuf is empty.
    {text The assertion that the string is empty
        is... {value sb.empty?}}
}


concat (メソッド)
public {WritableString.concat str:StringInterface}:void

StringInterfaceself に連結します。

str: StringInterface を連結する文字。このオブジェクトのデータ型は self と同じでなければなりません。

説明

strself の末尾に追加します。


{value
    || Declare and initialize two StringBufs.
    let sb1:StringBuf = {StringBuf "Hello World!"}
    let sb2:StringBuf = {StringBuf " Can you hear me?"}

    || Concatenate "sb2" onto "sb1".
    {sb1.concat sb2}

    || Display the resulting StringBuf.
    {value sb1}
}


insert (メソッド)
public abstract {WritableString.insert c:char, index:int}:void

文字を self に挿入します。

c: 挿入する文字。
index: 文字を挿入する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0self.size の範囲です (0self.size を含む)。

説明

位置 index より後ろにあるすべての文字を 1 つずつ後ろにずらし、位置 index に文字 c を挿入します。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Insert a comma (,) at position 5.
    || Remember that the leftmost position
    || is 0 (zero).
    {sb.insert ',', 5}

    || Display the resulting StringBuf.
    {value sb}
}

注意事項

これは WritableString の抽象メソッドです。このメソッドは WritableString のサブクラスによって実装されます。


remove (メソッド)
public abstract {WritableString.remove
index:int,
length:int = 1,
error-if-missing?:bool = true
}:void

指定された文字を self から削除します。

index: 文字の削除を開始する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0self.size の範囲です (0self.size を含む)。
length: 削除する文字数。length の既定値は 1 です。length はキーワード引数です。length を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:length = 6)。
error-if-missing?:
存在しない文字を削除しようとしたときにこのメソッドがエラーを生成するかどうかを示す、ブール値のフラグ。位置 0 と self.size の間の文字を削除できます。
error-if-missing?true に設定した場合、存在しない文字を削除しようとするとエラーがスローされます。エラーが発生するとプログラムの実行が停止し、エラー メッセージが表示されます。既定では、error-if-missing?true です。error-if-missing?false に設定した場合、エラーは生成されません。また、有効な範囲内にある文字は削除されますが、有効な範囲内にない文字は削除されず、削除後の文字列が返されます。
error-if-missing? はキーワード引数です。error-if-missing? を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:error-if-missing? = false)。

説明

self から length 個の文字を削除します。削除開始位置は index です。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Remove 6 characters, starting at
    || position 5.
    || Remember that the leftmost position
    || is 0 (zero).
    {sb.remove 5, length = 6}

    || Display the resulting StringBuf.
    {value sb}
}

注意事項

これは WritableString の抽象メソッドです。このメソッドは WritableString のサブクラスによって実装されます。


replace (メソッド)
public {WritableString.replace
old:StringInterface,
new:StringInterface,
starting-index:int = 0
}:void

old の各オカレンスを new に置換します。

old: new で置換する部分文字列。
new: old の各オカレンスを置換する部分文字列。

説明

左から右に部分文字列 old を検索します。各オカレンスごとに、old を削除し、new をつなぎ合わせて、新規に挿入された文字のから検索を再開します。


{value
    || Declare and initialize a string
    let sb:StringBuf = {StringBuf "Silly willy"}

    || Replace each occurrence of "ill" with "ick".
    {sb.replace "ill", "ick"}

    || Display the resulting StringBuf.
    sb
}


reverse (メソッド)
public {WritableString.reverse}:void

self 内の文字の順序を逆にします。


{value
    || Declare and initialize a StringBuf
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Reverses the order of the characters
    {sb.reverse}

    || Display the resulting StringBuf
    {value sb}
}

注意事項

このメソッドは、self に格納されている個々の char の順序を逆にします。Unicode 文字列の意味はその表現の個々の char の順序に依存するので、このメソッドは元の文字列を反転したものを生成しません。
例えば、文字シーケンス "\u305D\u3099\u305F" によって表される文字列は "\u305E\u305F" (ZO-TA) と同じですが、反転されると "\u3060\u305D" (SO-DA) と同じものになります。


set (メソッド)
public abstract {WritableString.set index:int, c:char}:void

self 内の文字を置換します。

index: 置換する文字の位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0(self.size - 1) の範囲です (0(self.size - 1) を含む)。
c: 新しい文字。

説明

位置 index にある文字を c に置換します。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Replace character 11 (!) with a period (.).
    || Remember that the leftmost position
    || is 0 (zero).
    {sb.set 11, '.'}

    || Display the resulting StringBuf.
    {value sb}
}

注意事項

これは WritableString の抽象メソッドです。このメソッドは WritableString のサブクラスによって実装されます。


set-contents (メソッド)
public {WritableString.set-contents str:StringInterface}:void

self の内容を別の文字列の内容に置換します。

str: self を置換する文字列を含む StringInterface


{value
    || Declare and initialize a StringBuf
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Replace the contents
    {sb.set-contents {StringBuf "Here comes Curl!"}}

    || Display the StringBuf
    {value sb}
}


splice (メソッド)
public {WritableString.splice str:StringInterface, index:int}:void

StringInterfaceself に挿入します。

str: 挿入する StringInterface。このオブジェクトのデータ型は self と同じでなければなりません。
index: StringInterface を挿入する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0self.size の範囲です (0self.size を含む)。

説明

self 内の位置 index より後ろにある文字を str の文字数分後ろにずらし、位置 indexstr を挿入します。


{value
    || Declare and initialize two StringBufs.
    let sb1:StringBuf = {StringBuf "Hello World!"}
    let sb2:StringBuf = {StringBuf ", can you hear me,"}

    || Insert "sb2" into "sb1" at position 5.
    || Remember that the leftmost position
    || is 0 (zero).
    {sb1.splice sb2, 5}

    || Display the resulting StringBuf.
    {value sb1}
}


to-lower (メソッド)
public {WritableString.to-lower}:void

self 内の文字を小文字に変更します。


{value
    || Declare and initialize a StringBuf
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Change the characters to lowercase
    {sb.to-lower}

    || Display the resulting StringBuf
    {value sb}
}


to-upper (メソッド)
public {WritableString.to-upper}:void

self 内の文字を大文字に変更します。


{value
    || Declare and initialize a StringBuf
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Change the characters to uppercase
    {sb.to-upper}

    || Display the resulting StringBuf
    {value sb}
}


trim (メソッド)
public {WritableString.trim
trim-chars:CharClass = CharClass.whitespace-chars
}:void

self の先頭および末尾の文字を削除します。

trim-chars: 削除する文字。trim-chars の既定値は、現在のロケールに対する空白 (CharClass.whitespace-chars で定義) を意味する文字群です。このメソッド呼び出しに対して既定値以外のトリミング対象文字を指定するには、その文字を含む CharClass を指定します。trim-chars はキーワード引数です。trim-chars を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:trim-chars = {CharClass " .,;:"})。

説明

trim-chars で指定された文字を、self の左端から順に削除します。この処理を、trim-chars で指定されていない文字が出現するまで続けます。同じ処理を self の右端に対しても実行します。

trim-chars で指定した文字がトリミング対象外の文字の間に出現した場合は、削除されません。たとえば、スペースがトリミング対象文字になっている場合、文字列の先頭と末尾にあるスペースは削除されますが、単語の間にあるスペースは削除されません。


{value
    || Declare and initialize a string.
    let sb:StringBuf = {StringBuf "  Hello World!  "}

    || Trim whitespace characters from the
    || start and the end.
    {sb.trim}

    || Display the resulting StringBuf.
    || The # characters are used to indicate
    || beginning and end of the string.
    {pre #{value sb}#}
}


trim-left (メソッド)
public {WritableString.trim-left
trim-chars:CharClass = CharClass.whitespace-chars
}:void

self の先頭の文字を削除します。

trim-chars: 削除する文字。trim-chars の既定値は、現在のロケールに対する空白 (CharClass.whitespace-chars で定義) を意味する文字群です。このメソッド呼び出しに対して既定値以外のトリミング対象文字を指定するには、その文字を含む CharClass を指定します。trim-chars はキーワード引数です。trim-chars を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:trim-chars = {CharClass " .,;:"})。

説明

trim-chars で指定された文字を、self の左端から順に削除します。この処理を、trim-chars で指定されていない文字が出現するまで続けます。


{value
    || Declare and initialize a string
    let sb:StringBuf = {StringBuf "  Hello World!  "}

    || Trim whitespace characters from the start.
    {sb.trim-left}

    || Display the resulting StringBuf
    || The # characters are used to indicate
    || beginning and end of the string
    {pre #{value sb}#}
}


trim-right (メソッド)
public {WritableString.trim-right
trim-chars:CharClass = CharClass.whitespace-chars
}:void

self の末尾の文字を削除します。

trim-chars: 削除する文字。trim-chars の既定値は、現在のロケールに対する空白 (CharClass.whitespace-chars で定義) を意味する文字群です。このメソッド呼び出しに対して既定値以外のトリミング対象文字を指定するには、その文字を含む CharClass を指定します。trim-chars はキーワード引数です。trim-chars を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:trim-chars = {CharClass " .,;:"})。

説明

trim-chars で指定された文字を、self の右端から順に削除します。この処理を、trim-chars で指定されていない文字が出現するまで続けます。


{value
    || Declare and initialize a string
    let sb:StringBuf = {StringBuf "  Hello World!  "}

    || Trim whitespace characters from the end.
    {sb.trim-right}

    || Display the resulting StringBuf
    || The # characters are used to indicate
    || beginning and end of the string
    {pre #{value sb}#}
}