mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 09:08:08 +08:00
doc: update doc for thread-local colorization
This commit is contained in:
@@ -12,14 +12,23 @@ In terminals or other output destinations that do not support ANSI escape code,
|
|||||||
|
|
||||||
## Macros
|
## Macros
|
||||||
|
|
||||||
```cpp
|
### `TOML11_COLORIZE_ERROR_MESSAGE`
|
||||||
TOML11_COLORIZE_ERROR_MESSAGE
|
|
||||||
```
|
|
||||||
|
|
||||||
If this macro is defined during compilation (`-DTOML11_COLORIZE_ERROR_MESASGE`), error messages are colored by default.
|
If this macro is defined during compilation (`-DTOML11_COLORIZE_ERROR_MESASGE`), error messages are colored by default.
|
||||||
|
|
||||||
If not defined, colors are not applied by default. You need to specify them using `toml::color::enable()`.
|
If not defined, colors are not applied by default. You need to specify them using `toml::color::enable()`.
|
||||||
|
|
||||||
|
### `TOML11_USE_THREAD_LOCAL_COLORIZATION`
|
||||||
|
|
||||||
|
If this macro is defined during compilation (`-DTOML11_USE_THREAD_LOCAL_COLORIZATION`), the colorization flag becomes `thread_local`.
|
||||||
|
In this case, `toml::color::enable()` or `toml::color::disable()` will only affect the colorization flag in the thread that called it.
|
||||||
|
This means that if you want to use a different setting from the default, you will need to set it again when starting a new thread.
|
||||||
|
This makes `toml::color::enable()` and `toml::color::disable()` thread safe.
|
||||||
|
|
||||||
|
By default, the setting is global.
|
||||||
|
When it is global, if one thread executes `toml::color::enable()`, the error messages will be colored in all threads.
|
||||||
|
However, if one thread executes `enable()` or `disable()` while another executes `enable()`, `disable()` or `should_color()`, the result is undefined.
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
### `enable()`
|
### `enable()`
|
||||||
|
@@ -12,9 +12,7 @@ ANSIエスケープシーケンスをサポートしていないターミナル
|
|||||||
|
|
||||||
## マクロ
|
## マクロ
|
||||||
|
|
||||||
```cpp
|
### `TOML11_COLORIZE_ERROR_MESSAGE`
|
||||||
TOML11_COLORIZE_ERROR_MESSAGE
|
|
||||||
```
|
|
||||||
|
|
||||||
コンパイル時にこのマクロが定義されていた場合(`-DTOML11_COLORIZE_ERROR_MESASGE`)、
|
コンパイル時にこのマクロが定義されていた場合(`-DTOML11_COLORIZE_ERROR_MESASGE`)、
|
||||||
デフォルトでエラーメッセージに色が付きます。
|
デフォルトでエラーメッセージに色が付きます。
|
||||||
@@ -22,6 +20,17 @@ TOML11_COLORIZE_ERROR_MESSAGE
|
|||||||
定義されていなかった場合、デフォルトでは色は付きません。以下の `toml::color::enable()` を
|
定義されていなかった場合、デフォルトでは色は付きません。以下の `toml::color::enable()` を
|
||||||
使用して指定する必要があります。
|
使用して指定する必要があります。
|
||||||
|
|
||||||
|
### `TOML11_USE_THREAD_LOCAL_COLORIZATION`
|
||||||
|
|
||||||
|
コンパイル時にこのマクロが定義されていた場合(`-DTOML11_COLORIZE_ERROR_MESASGE`)、
|
||||||
|
`toml::color::enable`の設定が`thread_local`になります。
|
||||||
|
この場合、`toml::color::enable()`や`toml::color::disable()`は、それを呼び出したスレッドでの設定しか変更しません。
|
||||||
|
つまり、新しいスレッドを起動した際にデフォルトと異なる設定にしたい場合は、再度設定が必要になります。
|
||||||
|
その代わり、`toml::color::enable()`や`toml::color::disable()`はスレッドセーフになります。
|
||||||
|
|
||||||
|
デフォルトでは設定はグローバルです。
|
||||||
|
グローバルの場合、一つのスレッドが`toml::color::enable()`を実行した場合、すべてのスレッドで色が付きます。
|
||||||
|
ただし、あるスレッドが`enable()`または`disable()`を実行している間に別のスレッドが`enable()`、`disable()`、`should_color()`を実行した場合、その結果は未定義です。
|
||||||
|
|
||||||
## 関数
|
## 関数
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user