Skip to content

Commit

Permalink
#344: docs: add user traits example
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Feb 17, 2025
1 parent e49c958 commit 0c95c03
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion docs/md/checkpoint_learn_example_traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ The full code for this *magistrate* example can be found here:

\subsubsection ex7 Example source code:
\snippet examples/checkpoint_example_traversal.cc Serialization with custom traverser

9 changes: 9 additions & 0 deletions docs/md/checkpoint_learn_example_user_traits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\page cpkt_learn_user_traits Program Example User Traits

The full code for this *magistrate* example can be found here:
`examples/checkpoint_example_user_traits.cc`

\subsubsection user_traits Example source code:
\snippet examples/checkpoint_example_user_traits.h Serialization with user traits (header)
\snippet examples/checkpoint_example_user_traits.cc Serialization with user traits

1 change: 1 addition & 0 deletions docs/md/checkpoint_learn_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| checkpoint_example_5_polymorphic | Serialization of polymorphic class hierarchy | \subpage ckpt_learn_ex5_polymorphic |
| checkpoint_example_6_polymorphic_macro | Serialization of polymorphic class hierarchy with macros | \subpage ckpt_learn_ex6_polymorphic_macro |
| checkpoint_example_7_traversal | Serialization with custom traverser | \subpage ckpt_learn_ex7_traversal |
| checkpoint_example_user_traits | Serialization with user traits | \subpage cpkt_learn_user_traits |

 
 
Expand Down
5 changes: 5 additions & 0 deletions examples/checkpoint_example_user_traits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
// *****************************************************************************
//@HEADER
*/

/// [Serialization with user traits]

#include "checkpoint/checkpoint.h"

#include "checkpoint_example_user_traits.h"
Expand All @@ -59,3 +62,5 @@ int main(int, char**){
auto s_info_h = checkpoint::serialize<TestObj, misc::namespace_trait>(obj);
auto s_info_i = checkpoint::serialize<TestObj, misc::hook_all_trait>(obj);
}

/// [Serialization with user traits]
4 changes: 4 additions & 0 deletions examples/checkpoint_example_user_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#if !defined INCLUDED_EXAMPLES_CHECKPOINT_EXAMPLE_USER_TRAITS_H
#define INCLUDED_EXAMPLES_CHECKPOINT_EXAMPLE_USER_TRAITS_H

/// [Serialization with user traits (header)]

#include <checkpoint/checkpoint.h>

struct checkpoint_trait {} CheckpointTrait;
Expand Down Expand Up @@ -154,4 +156,6 @@ namespace misc {
}
}

/// [Serialization with user traits (header)]

#endif /*INCLUDED_EXAMPLES_CHECKPOINT_EXAMPLE_USER_TRAITS_H*/

0 comments on commit 0c95c03

Please sign in to comment.