Skip to content

Commit

Permalink
Fixed typos in the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzicheng1987 committed Nov 7, 2024
1 parent beb27d4 commit 88cf229
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/processors.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ The resulting JSON string looks like this:
{"type":"Person","first_name":"Homer","last_name":"Simpson","age":45}
```

### `rfl::AddStructsToVariants`
### `rfl::AddTagsToVariants`

This processor automatically adds structs to variants. Consider the following example:
This processor automatically adds tags to variants. Consider the following example:

```cpp
struct button_pressed_t {};
Expand All @@ -79,8 +79,8 @@ using my_event_type_t =
std::variant<button_pressed_t, button_released_t, key_pressed_t, int>;
```
The problem here is that `button_pressed_t` and `butten_released_t` virtually look
indistinguishable. The will both be serialized to `{}`.
The problem here is that `button_pressed_t` and `button_released_t` virtually look
indistinguishable when they are serialized. The will both be serialized to `{}`.
But you can add this processor to automatically add tags and avoid the problem:
Expand Down Expand Up @@ -114,6 +114,9 @@ struct key_pressed_t {
{"your_custom_tag":{"key":99}}
```

Note that there are other ways to address problems like this, for instance `rfl::TaggedUnion`.
Please refer to the relevant sections of the documentation.

### `rfl::AllowRawPtrs`

By default, reflect-cpp does not allow *reading into* raw pointers. (*Writing from* raw pointers is never a problem.) This is because reading into raw pointers means that the library will allocate memory that the user then has to manually delete. This can lead to misunderstandings and memory leaks.
Expand Down

0 comments on commit 88cf229

Please sign in to comment.