Skip to content

Commit ad5310e

Browse files
committed
String to Str
1 parent 5e2ebd7 commit ad5310e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+361
-361
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ JSON 存在六种基本类型,本库使用了一个枚举来表示它们:
3333

3434
```cpp
3535
enum class Type{
36-
eNul = 0, ///< Nul type
36+
eNul = 0, ///< null type
3737
eBol, ///< boolean type
38-
eNum, ///< Num type
39-
eString, ///< String type
40-
eArray, ///< Array type
41-
eObject ///< Object type
38+
eNum, ///< number type
39+
eStr, ///< string type
40+
eArray, ///< array type
41+
eObject ///< object type
4242
};
4343
```
4444

@@ -76,7 +76,7 @@ namespace mysvac {
7676
| `Json::Nul` | `std::nullptr_t` | `std::nullptr_t` |
7777
| `Json::Bol` | `bool` | `bool` |
7878
| `Json::Num` | `double` | `double` |
79-
| `Json::String` | `std::string` | `std::basic_string<...,StrAllocator<char>>` |
79+
| `Json::Str` | `std::string` | `std::basic_string<...,StrAllocator<char>>` |
8080
| `Json::Array` | `std::vector<Json>` | `std::vector<Json, VecAllocator<Json>>` |
8181
| `Json::Object` | `std::map<std::string, Json>` | `std::map<..,MapAllocator<..>>` 或 `std::unordered_map<..,MapAllocator<..>>` |
8282
@@ -383,7 +383,7 @@ v_data["id"] == 42; // true
383383

384384
```cpp
385385
struct MyData2 {
386-
std::string name; // std::string 等于 json::String,因此可以直接使用
386+
std::string name; // std::string 等于 json::Str,因此可以直接使用
387387
MyData my_data; // MyData 已经有转换函数和构造函数,因此可以直接使用
388388
std::vector<MyData> data_list; // 能够直接使用的类型构成的列表也能直接使用(但再套一层列表就不行了)
389389
MyData2() = default;

docs/zh/Json/Json.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ Each `Json` class internally contains six types corresponding to the six JSON da
4242
using Nul = std::nullptr_t;
4343
using Bol = bool;
4444
using Num = double;
45-
using String = std::basic_string<char, std::char_traits<char>, StrAllocator<char>>;
45+
using Str = std::basic_string<char, std::char_traits<char>, StrAllocator<char>>;
4646
using Array = std::vector<Json, VecAllocator<Json>>;
4747
using Object = std::conditional_t<UseOrderedMap,
48-
std::map<String, Json, std::less<String>, MapAllocator<std::pair<const String, Json>>>,
49-
std::unordered_map<String, Json, std::hash<String>, std::equal_to<String>, MapAllocator<std::pair<const String, Json>>>
48+
std::map<Str, Json, std::less<Str>, MapAllocator<std::pair<const Str, Json>>>,
49+
std::unordered_map<Str, Json, std::hash<Str>, std::equal_to<Str>, MapAllocator<std::pair<const Str, Json>>>
5050
>;
5151
```
5252

53-
The types for `Nul`, `Bol` and `Num` are completely fixed. For `String`, `Array` and `Object`, the memory allocator can be customized through template parameter `AllocatorType`.
53+
The types for `Nul`, `Bol` and `Num` are completely fixed. For `Str`, `Array` and `Object`, the memory allocator can be customized through template parameter `AllocatorType`.
5454
While `Object` can choose between ordered or hash-based implementations, the class templates themselves remain fixed.
5555

5656
By default:
57-
- `String` equals `std::string`
57+
- `Str` equals `std::string`
5858
- `Array` equals `std::vector<Json>`
59-
- `Object` equals `std::map<String, Json>`
59+
- `Object` equals `std::map<Str, Json>`
6060

6161
## Member Variables
6262

@@ -68,7 +68,7 @@ std::variant<
6868
Nul,
6969
Bol,
7070
Num,
71-
String,
71+
Str,
7272
Array,
7373
Object
7474
> m_data { Nul{} };
@@ -88,13 +88,13 @@ std::variant<
8888
- [is_nul](is_nul.md): Check if current JSON is `Nul`
8989
- [is_bol](is_bol.md): Check if current JSON is `Bol`
9090
- [is_num](is_num.md): Check if current JSON is `Num`
91-
- [is_str](is_str.md): Check if current JSON is `String`
91+
- [is_str](is_str.md): Check if current JSON is `Str`
9292
- [is_arr](is_arr.md): Check if current JSON is `Array`
9393
- [is_obj](is_obj.md): Check if current JSON is `Object`
9494
- [nul](get_nul.md): Get reference to internal `Nul` data
9595
- [bol](get_bol.md): Get reference to internal `Bol` data
9696
- [num](get_num.md): Get reference to internal `Num` data
97-
- [str](get_str.md): Get reference to internal `String` data
97+
- [str](get_str.md): Get reference to internal `Str` data
9898
- [arr](get_arr.md): Get reference to internal `Array` data
9999
- [obj](get_obj.md): Get reference to internal `Object` data
100100

docs/zh/Json/at.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
```cpp
44
// 1
5-
Json& at(const String& key);
5+
Json& at(const Str& key);
66

77
// 2
8-
const Json& at(const String& key) const;
8+
const Json& at(const Str& key) const;
99

1010
// 3
1111
Json& at(const std::size_t index);

docs/zh/Json/contains.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# **Json.contains**
22

33
```cpp
4-
bool contains(const String& key) const noexcept;
4+
bool contains(const Str& key) const noexcept;
55
```
66
77
Checks if an `Object` contains the specified key, returns `false` for non-object types.

docs/zh/Json/dump.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# **Json.dump**
22

33
```cpp
4-
String dump() const noexcept;
4+
Str dump() const noexcept;
55
```
66

77
Serializes JSON data to a string and returns the result.

docs/zh/Json/dumpf.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# **Json.dumpf**
22

33
```cpp
4-
String dumpf(
4+
Str dumpf(
55
const std::uint16_t space_num = 2,
66
const std::uint16_t depth = 0
77
) const noexcept;
@@ -14,7 +14,7 @@ Serializes JSON data to a formatted string and returns the result.
1414
- **`depth`**: Initial indentation depth (unsigned integer, default=0)
1515

1616
### Return Value
17-
Returns a `String` object containing the formatted JSON:
17+
Returns a `Str` object containing the formatted JSON:
1818
- Properly indented with `space_num` spaces per level
1919
- Starting from specified `depth` level
2020

docs/zh/Json/empty.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Checks if the container is empty for `Object`/`Array`, returns `true` for other
88

99
**Return Value**
1010
- `Object`/`Array`: `true` if empty (equivalent to `size() == 0`)
11-
- All other types: `true` (including `String`)
11+
- All other types: `true` (including `Str`)
1212

1313
**Exception Safety**
1414
No-throw guarantee

docs/zh/Json/erase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```cpp
44
// 1
5-
bool erase(const String& key) noexcept;
5+
bool erase(const Str& key) noexcept;
66

77
// 2
88
bool erase(const std::size_t index) noexcept;

docs/zh/Json/get_str.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# **Json.str**
22

33
```cpp
4-
constexpr String& str() & ;
5-
constexpr String&& str() && ;
6-
constexpr const String& str() const & ;
7-
constexpr const String&& str() const && ;
4+
constexpr Str& str() & ;
5+
constexpr Str&& str() && ;
6+
constexpr const Str& str() const & ;
7+
constexpr const Str&& str() const && ;
88
```
99

1010
Returns a reference to the internal string value.

docs/zh/Json/insert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```cpp
44
// 1
55
template<typename K, typename V>
6-
requires std::convertible_to<K, String> && std::convertible_to<V, Json>
6+
requires std::convertible_to<K, Str> && std::convertible_to<V, Json>
77
bool insert(K&& key, V&& value) noexcept;
88

99
// 2

0 commit comments

Comments
 (0)