You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70-89Lines changed: 70 additions & 89 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@
8
8
9
9
KeyValues is a simple key-value pair format used by Valve in Steam and the Source engine for configuration files, game data, and more (`.vdf`, `.res`, `.acf`, etc.). This library aims to be fully compatible with Valve's various implementations of KeyValues format parsing (believe us, it's not consistent).
10
10
11
-
# Core Types
11
+
# Core Type
12
12
13
-
The library is built around two types:
13
+
The library is built around a single type:
14
14
15
-
-**`KVObject`** (class) -- a named tree node. Holds a `Name` and a `KVValue`. Supports navigation, mutation, and enumeration.
16
-
-**`KVValue`** (readonly record struct) -- the data. Stores scalars inline (no boxing), strings, binary blobs, arrays, and collections. Supports implicit/explicit conversions, flags, and `with` expressions.
15
+
-**`KVObject`** (class) -- a value node. Can be a scalar (string, int, float, bool, etc.), a binary blob, an array, or a named collection of children. Keys (names) are stored in the parent container, not on the child -- similar to how JSON works.
16
+
-**`KVDocument`** (class, extends `KVObject`) -- a deserialized document with a root key `Name`and optional `Header`.
17
17
18
18
All types are shared across KV1 and KV3 -- you can deserialize from one format and serialize to another. However, not all value types are supported by all formats:
19
19
@@ -32,46 +32,46 @@ When constructing objects programmatically, use `KVObject.Collection()` (dict-ba
32
32
### Constructing
33
33
34
34
```csharp
35
-
// Scalar value (typed constructors for common types, no cast needed)
36
-
varobj=newKVObject("key", "hello");
37
-
varobj=newKVObject("key", 42);
38
-
varobj=newKVObject("key", 3.14f);
39
-
varobj=newKVObject("key", true);
35
+
// Scalar values (typed constructors)
36
+
varobj=newKVObject("hello"); // string
37
+
varobj=newKVObject(42); // int
38
+
varobj=newKVObject(3.14f); // float
39
+
varobj=newKVObject(true); // bool
40
+
41
+
// Implicit conversion from primitives
42
+
KVObjectobj="hello";
43
+
KVObjectobj=42;
40
44
41
45
// Dictionary-backed collection (O(1) lookup, no duplicate keys)
42
-
varobj=KVObject.Collection("root"); // empty, can Add children
43
-
varobj=KVObject.Collection("root", [ // with children
0 commit comments