diff options
Diffstat (limited to 'src/variable.cpp')
-rw-r--r-- | src/variable.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/variable.cpp b/src/variable.cpp index 99bac59..87571b6 100644 --- a/src/variable.cpp +++ b/src/variable.cpp | |||
@@ -890,3 +890,84 @@ Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v ) | |||
890 | return f; | 890 | return f; |
891 | } | 891 | } |
892 | 892 | ||
893 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Variable &v ) | ||
894 | { | ||
895 | ar << (int8_t)v.eType; | ||
896 | switch( v.eType ) | ||
897 | { | ||
898 | case Variable::typeNone: | ||
899 | break; | ||
900 | |||
901 | case Variable::typeBool: | ||
902 | ar << v.uVal.bVal; | ||
903 | break; | ||
904 | |||
905 | case Variable::typeInt: | ||
906 | ar << v.uVal.iVal; | ||
907 | break; | ||
908 | |||
909 | case Variable::typeFloat: | ||
910 | ar << v.uVal.fVal; | ||
911 | break; | ||
912 | |||
913 | case Variable::typeVersion: | ||
914 | break; | ||
915 | |||
916 | case Variable::typeString: | ||
917 | ar << *v.uVal.sVal; | ||
918 | break; | ||
919 | |||
920 | case Variable::typeList: | ||
921 | ar << *v.uVal.lVal; | ||
922 | break; | ||
923 | |||
924 | case Variable::typeRef: | ||
925 | ar << *v.uVal.sVal; | ||
926 | break; | ||
927 | } | ||
928 | |||
929 | return ar; | ||
930 | } | ||
931 | |||
932 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Variable &v ) | ||
933 | { | ||
934 | int8_t t; | ||
935 | ar >> t; | ||
936 | v.eType = (Variable::Type)t; | ||
937 | v.reset( v.eType ); | ||
938 | switch( v.eType ) | ||
939 | { | ||
940 | case Variable::typeNone: | ||
941 | break; | ||
942 | |||
943 | case Variable::typeBool: | ||
944 | ar >> v.uVal.bVal; | ||
945 | break; | ||
946 | |||
947 | case Variable::typeInt: | ||
948 | ar >> v.uVal.iVal; | ||
949 | break; | ||
950 | |||
951 | case Variable::typeFloat: | ||
952 | ar >> v.uVal.fVal; | ||
953 | break; | ||
954 | |||
955 | case Variable::typeVersion: | ||
956 | break; | ||
957 | |||
958 | case Variable::typeString: | ||
959 | ar >> *v.uVal.sVal; | ||
960 | break; | ||
961 | |||
962 | case Variable::typeList: | ||
963 | ar >> *v.uVal.lVal; | ||
964 | break; | ||
965 | |||
966 | case Variable::typeRef: | ||
967 | ar >> *v.uVal.sVal; | ||
968 | break; | ||
969 | } | ||
970 | |||
971 | return ar; | ||
972 | } | ||
973 | |||