cgv
Loading...
Searching...
No Matches
ascii_io_reflection_handlers.h
1#pragma once
2
3#include <iostream>
4#include <fstream>
5#include "io_reflection_handler.h"
6
7#include "lib_begin.h"
8
9namespace cgv {
10 namespace data {
11
13 enum NamingConvention { NC_NONE, NC_SHORT, NC_LONG };
14 }
15}
16
17namespace cgv {
18 namespace reflect {
19 extern CGV_API enum_reflection_traits<cgv::data::NamingConvention> get_reflection_traits(const cgv::data::NamingConvention&);
20 }
21}
22
23namespace cgv {
24 namespace data {
25
26
29{
30public:
31protected:
32 unsigned nr_idents;
33
34 NamingConvention naming_convention;
35 unsigned tab_size;
36
37 std::string extend_name(const std::string& name, bool assign = true);
38public:
40 bool reflect_header();
42 ascii_reflection_handler(const std::string& _content, unsigned _ver, unsigned _tab = 3);
44 int reflect_group_begin(GroupKind group_kind, const std::string& group_name, void* group_ptr, cgv::reflect::abst_reflection_traits* rt, unsigned grp_size);
46 void reflect_group_end(GroupKind group_kind);
47};
48
51{
52protected:
53 std::ifstream file_is;
54 std::istream& is;
55
56 bool read_reflect_header(const std::string& _content, unsigned _ver);
57public:
58 ascii_read_reflection_handler(const std::string& file_name, const std::string& _content, unsigned _ver, NamingConvention _nc = NC_SHORT, unsigned _tab = 3);
60 ascii_read_reflection_handler(std::istream& _is, const std::string& _content, unsigned _ver, NamingConvention _nc = NC_SHORT, unsigned _tab = 3);
62 bool is_creative() const;
64 void close();
65 int reflect_group_begin(GroupKind group_kind, const std::string& group_name, void* group_ptr, cgv::reflect::abst_reflection_traits* rt, unsigned grp_size);
67 bool reflect_member_void(const std::string& member_name,
68 void* member_ptr, cgv::reflect::abst_reflection_traits* rt);
69};
70
71
74{
75protected:
76 std::ofstream file_os;
77 std::ostream& os;
78public:
80 ascii_write_reflection_handler(const std::string& file_name, const std::string& _content, unsigned _ver, NamingConvention _nc = NC_SHORT, unsigned _tab = 3);
82 ascii_write_reflection_handler(std::ostream& _os, const std::string& _content, unsigned _ver, NamingConvention _nc = NC_SHORT, unsigned _tab = 3);
84 bool failed() const;
86 void close();
88 int reflect_group_begin(GroupKind group_kind, const std::string& group_name, void* group_ptr, cgv::reflect::abst_reflection_traits* rt, unsigned grp_size);
90 bool reflect_member_void(const std::string& member_name,
91 void* member_ptr, cgv::reflect::abst_reflection_traits* rt);
92};
93
94
95 }
96}
97
98#include <cgv/config/lib_end.h>
common base for all io reflection handlers
GroupKind
different support group types
NamingConvention
different naming conventions for member names
the cgv namespace
Definition print.h:11
abstract interface for type reflection with basic type management and optional string conversion