設定データオブジェクト (cfg_data
)
このオブジェクトは、設定ファイルを生成するために使用される設定値をカプセル化します。より詳細な説明は、設定の wiki ページにあります。
返されるもの
設定データオブジェクトは、次の関数とメソッドによって返されます。
設定データオブジェクトのメソッド
cfg_data.get()
varname
の値を返します。値が設定されていない場合、default_value
が定義されていればそれを返し、定義されていなければエラーとなります (0.38.0 以降)。
シグネチャ
(0.38.0 以降)
# Returns the value of `varname`, if the
str | int | bool get(
str varname, # The name of the variable to query
str | int | bool [default_value], # The default value to return when `varname` does not exist
)
引数
メソッド cfg_data.get()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
varname |
str |
クエリする変数の名前 |
|
default_value |
str | int | bool |
|
[オプション] |
cfg_data.get_unquoted()
varname
の値を返しますが、二重引用符 ("
) で囲まれていません。値が設定されていない場合、default_value
が定義されていればそれを返し、定義されていなければエラーとなります。
シグネチャ
(0.44.0 以降)
# Returns the value
str | int | bool get_unquoted(
str varname, # The name of the variable to query
str | int | bool [default_value], # The default value to return when `varname` does not exist
)
引数
メソッド cfg_data.get_unquoted()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
varname |
str |
クエリする変数の名前 |
|
default_value |
str | int | bool |
|
[オプション] |
cfg_data.has()
指定された変数が設定されている場合は true
を返します。
シグネチャ
# returns `true` if the specified variable is set
bool has(
str varname, # The name of the variable to query
)
引数
メソッド cfg_data.has()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
varname |
str |
クエリする変数の名前 |
|
cfg_data.keys()
設定データオブジェクトのキーの配列を返します。
この配列は、foreach
ステートメントで反復処理できます。
シグネチャ
(0.57.0 以降)
list[str] keys()
cfg_data.merge_from()
別の設定データオブジェクトを引数として受け取り、そのオブジェクトのすべてのエントリを現在のオブジェクトにコピーします。
シグネチャ
(0.42.0 以降)
# Takes as argument a different
void merge_from(
cfg_data other, # The other cfg_data
object to merge into this one.
)
引数
メソッド cfg_data.merge_from()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
other |
cfg_data |
マージ先の別の |
|
cfg_data.set()
変数を指定された値に設定します。
シグネチャ
# Sets a variable to a given value
void set(
str varname, # The name of the variable to set
str | int | bool value, # The value to set
# Keyword arguments:
description : str # Message / Comment that will be written in the
)
引数
メソッド cfg_data.set()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
varname |
str |
設定する変数の名前 |
|
value |
str | int | bool |
設定する値 |
|
最後に、cfg_data.set()
は次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
description |
str |
結果ファイルに書き込まれるメッセージ/コメント。置換は、C 構文のファイルを想定しています。生成されたファイルが他の言語のソースコードである場合、構文エラーが発生する可能性が高いため、description フィールドを追加しない方がよいでしょう。 |
|
cfg_data.set10()
cfg_data.set()
と同じですが、値は true
または false
のいずれかで、それぞれ 1 または 0 として書き込まれます。
シグネチャ
# Is the same as cfg_data.set()
but the value
void set10(
str varname, # The name of the variable to set
bool | int value, # The value to set as either `1` or `0`
# Keyword arguments:
description : str # Message / Comment that will be written in the
)
数値 < 0 は true
に変換されるという驚くべき動作をし、数値 > 1 は true
として解釈されるという、より予想されるが意図しない動作をします。
引数
メソッド cfg_data.set10()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
varname |
str |
設定する変数の名前 |
|
value |
bool | int |
数値を渡すことは想定されておらず、0.62 以降は非推奨になりました。これは Meson の将来のバージョンで削除されます。数値を使用する必要がある場合は、 |
|
最後に、cfg_data.set10()
は次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
description |
str |
結果ファイルに書き込まれるメッセージ/コメント。置換は、C 構文のファイルを想定しています。生成されたファイルが他の言語のソースコードである場合、構文エラーが発生する可能性が高いため、description フィールドを追加しない方がよいでしょう。 |
|
cfg_data.set_quoted()
cfg_data.set()
と同じですが、値を二重引用符 ("
) で囲みます。
シグネチャ
# Is same as cfg_data.set()
but quotes the value in double quotes (`"`)
void set_quoted(
str varname, # The name of the variable to set
str | int | bool value, # The value to set
# Keyword arguments:
description : str # Message / Comment that will be written in the
)
引数
メソッド cfg_data.set_quoted()
は、次の位置引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
varname |
str |
設定する変数の名前 |
|
value |
str | int | bool |
設定する値 |
|
最後に、cfg_data.set_quoted()
は次のキーワード引数を受け取ります。
名前 | 型 | 説明 | タグ |
---|---|---|---|
description |
str |
結果ファイルに書き込まれるメッセージ/コメント。置換は、C 構文のファイルを想定しています。生成されたファイルが他の言語のソースコードである場合、構文エラーが発生する可能性が高いため、description フィールドを追加しない方がよいでしょう。 |
|
検索結果は次のとおりです