From fd56cdd21a7c9c944ad189cf91ff24d3c2b0f975 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 20 Apr 2022 14:04:47 -0700 Subject: Gradually moving to better archive structure. It's dragging other new API changes along with it, including use of Blob and Text. --- src/tests/archivetags.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/tests/archivetags.cpp (limited to 'src/tests') diff --git a/src/tests/archivetags.cpp b/src/tests/archivetags.cpp new file mode 100644 index 0000000..f0587fd --- /dev/null +++ b/src/tests/archivetags.cpp @@ -0,0 +1,73 @@ + +class SubThing +{ +public: + SubThing(); + virtual ~SubThing(); + + Bu::Blob bData; + Bu::Text tName; +}; + +class Something +{ +pubilc: + Something(); + virtual ~Something(); + + int iAge; + int iSize; + int *aiNumber; + SubThing xThing; +}; + +Bu::Archive &operator<<( Bu::Archive &ar, const SubThing &st ) +{ + Bu::Archive::Dictionary ds( ar ); + + return ar + << ar.tag("data") << st.bData + << ar.tag("name") << st.tName; +} + +Bu::Archive &operator>>( Bu::Archive &ar, SubThing &st ) +{ + Bu::Archive::Dictionary ds( ar ); + + return ar + >> ar.tag("data") >> st.bData + >> ar.tag("name") >> st.tName; +} + +Bu::Archive &operator<<( Bu::Archive &ar, const Something &st ) +{ + Bu::Archive::Dictionary ds( ar ); + ar << ar.tag("age") << st.iAge; + + ar.startList("number", st.iSize ); + for( int j = 0; j < st.iSize; j++ ) + { + ar << st.aiNumber[j]; + } + ar.endList(); + ar << ar.tag("thing") << st.xThing; + return ar; +} + +Bu::Archive &operator>>( Bu::Archive &ar, Something &st ) +{ + Bu::Archive::Dictionary ds( ar ); + ar >> ar.tag("age") >> st.iAge; + + ar.startList("number"); + int iSize = ar.getListSize(); + for( int j = 0; j < iSize; j++ ) + { + ar >> st.aiNumber[j]; + } + ar.endList(); + + ar >> ar.tag("thing") >> st.xThing; + return ar; +} + -- cgit v1.2.3