Skip to content

Commit

Permalink
Update usage.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Astari committed May 28, 2017
1 parent ba2684d commit 69ddd37
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions doc/usage.md
Expand Up @@ -3,7 +3,7 @@
![ThorStream](../img/stream.jpg)


##Marking your class Serializeable/Deserializable
## Marking your class Serializeable/Deserializable
* Include the header file: `ThorSerialize/Traits.h`
* Use one of these macros to declare your type as serializable
* `ThorsAnvil_MakeTrait(<Type>, <members>...)`
Expand Down Expand Up @@ -42,7 +42,7 @@ The two macros above build a template specialization of the class `ThorsAnvil::S
ThorsAnvil_MakeTrait(MyNameSpace::MyClass, x);
````
##Private Members
## Private Members
If any members of the class that need to be serialized are private you must define a friendship to allow the `Traits<X>` class to have access to the private members.
````c++
#include "ThorSerialize/Traits.h"
Expand All @@ -63,7 +63,7 @@ If any members of the class that need to be serialized are private you must defi
ThorsAnvil_MakeTrait(MyNameSpace::MyClass, x, y);
````

##Standard containers
## Standard containers
The appropriate declarations for all the standard containers are provided. You simply need to include "ThorSerialize/SerUtil.h" to include these declarations.
````c++
#include "ThorSerialize/SerUtil.h"
Expand All @@ -80,8 +80,8 @@ The appropriate declarations for all the standard containers are provided. You s
}
````
##Serialization
###Json
## Serialization
### Json
* Include the header file "ThorSerialize/JsonThor.h".
* There are two functions in the namespace `ThorsAnvil::Serialize`.
* `jsonExport(<YourObject>, characteristics = Default);`
Expand All @@ -105,7 +105,7 @@ On export there is a second parameter `characteristics` that allows some simple
Config: Human readable Potentially config file like.
````

###Yaml
### Yaml
The description above is for Json Serialization/Deserialization. But the exact same description can be used for Yaml. Simply replace Json with Yaml and replace json with yaml.

The export parameter `characteristics` has slightly different meaning for printing yaml. See the [libyaml documentation](http://libyaml.sourcearchive.com/documentation/0.1.1/group__styles_g1efef592e2e3df6f00432c04ef77d98f.html) for the meaning of these flags.
Expand All @@ -117,12 +117,12 @@ The export parameter `characteristics` has slightly different meaning for printi
Config: YAML_BLOCK_MAPPING_STYLE
````

###Binary
### Binary
The description above is for Json Serialization/Deserialization. But the exact same description can be used for Binary versions. Simply replace Json with Binary and replace json with binary.

The export parameter `characteristics` has no affect on binary.

##Notes on std::map (Json)
## Notes on std::map (Json)
The JSON "Object" is a set of "name"/"value" pairs. But the name part is always a "String". If you use a `std::map<Key, Value>` where the "Key" is a `std::string` then the `std::map<>` will be represented by a JSON "Object". If any other type is used as the "Key" then `std::map<>` will be represented as a Json "Array" where each member of the array is `std::pair<Key,Value>`.
````c++
// Example:
Expand All @@ -136,7 +136,7 @@ The JSON "Object" is a set of "name"/"value" pairs. But the name part is always
}
````
##Strict Vs Weak Parsing.
## Strict Vs Weak Parsing.
By defaul the parser is linient.
If it finds a "Key" that it does not recognize (or know how to decode) then it will ignore the "Value". This is controlled via the second parameter passed to the parser which defaults to "Weak"
Expand Down

0 comments on commit 69ddd37

Please sign in to comment.