Skip to content

Commit

Permalink
document update
Browse files Browse the repository at this point in the history
  • Loading branch information
injae committed Feb 5, 2021
1 parent e86970e commit 7186894
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include <serdepp/utility.hpp>
#include "serdepp/adaptor/nlohmann_json.hpp"
class bbb {
derive_serde(bbb, ctx.tag(str, "str")
.tag(x, "x", 10) // with default value ( need to std::optional type)
.tag(m, "m") // if not this key panic
.tag(om, "om")
.tag(v, "v")
derive_serde(bbb, ctx.TAG(str)
.TAG(x) // with default value ( need to std::optional type)
.TAG(m) // if not this key panic
.TAG(om)
.TAG(v)
.no_remain(); // remain data check
)
public:
Expand Down Expand Up @@ -57,16 +57,16 @@ int main(int argc, char* argv[]) {
class in {
derive_serde(in, ctx.tag(text, "text");)
derive_serde(in, ctx.TAG(text);)
std::string text;
};
class bbb {
derive_serde(bbb, ctx.tag(str, "str")
.tag(x, "x", 10) // with default value ( need to std::optional type)
.tag(m, "m") // if not this key panic
.tag(om, "om")
.tag(v, "v")
derive_serde(bbb, ctx.TAG(str)
.TAG(x, 10) // with default value ( need to std::optional type)
.TAG(m) // if not this key panic
.TAG(om)
.TAG(v)
.no_remain(); // remain data check
)
public:
Expand All @@ -82,9 +82,9 @@ private:
class ttt {
// macro version <- need to #include<serdepp/utility.hpp>
derive_serde(ttt,
ctx.tag(bbb, "bbb")
.tag(inmap, "inmap")
.tag(str, "str");
ctx.TAG(bbb)
.TAG(inmap)
.TAG(str);
)
// no macro version
//friend serde::serializer<ttt>;
Expand Down Expand Up @@ -169,11 +169,11 @@ struct author {
struct convert {
derive_serde(convert,
ctx.tag(cpp, "cpp")
.tag(lib, "lib")
.tag(repo, "repo")
.tag(toml, "toml")
.tag(author, "author")
ctx.TAG(cpp)
.TAG(lib)
.TAG(repo)
.TAG(toml)
.TAG(author)
.no_remain();)
std::vector<int> cpp;
Expand Down Expand Up @@ -279,16 +279,17 @@ int main(int argc, char* argv[]) {
```
## Benchmark
serdepp's serializer vs nlohmann_json's serialer
```
struct TestStruct {
### Serializer Define Example
```cpp
struct TestStruct { // can support struct <-> json toml string ...
derive_serde(TestStruct, ctx.TAG(str).TAG(i).TAG(vec);)
std::optional<std::string> str;
int i;
std::vector<std::string> vec;
};
namespace ns {
struct TestStruct2 {
struct TestStruct2 { // only struct <-> json
std::string str;
int i;
std::vector<std::string> vec;
Expand All @@ -309,7 +310,7 @@ Load Average: 2.20, 2.20, 2.23
-------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------------------
serialize_struct_serde_nlohmann_json 255 ns 254 ns 2784906
serialize_struct_serde_nlohmann_json 255 ns 254 ns 2784906 (need to optimize)
serialize_struct_nlohmann_json 169 ns 168 ns 4616775
deserialize_serde_nlohmann_json 1848 ns 1842 ns 424721
deserialize_nlohmann_json 1916 ns 1910 ns 407055
Expand Down

0 comments on commit 7186894

Please sign in to comment.