Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
yksten committed Dec 15, 2024
1 parent 9f083cc commit b9c5e80
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 46 deletions.
5 changes: 0 additions & 5 deletions include/struct2x/json/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ namespace struct2x {

// convert by field type
JSONDecoder& setConvertByType(bool convertByType);

template<typename T>
JSONDecoder& operator&(serializeItem<T> value) {
return convert(value.name, *(typename internal::TypeTraits<T>::Type*)(&value.value), value.bHas);
}

template<typename T>
JSONDecoder& convert(const char* name, T& value, bool* pHas = NULL) {
Expand Down
5 changes: 0 additions & 5 deletions include/struct2x/json/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ namespace struct2x {
explicit JSONEncoder(std::string& str, bool formatted = false);
~JSONEncoder();

template<typename T>
JSONEncoder& operator&(const serializeItem<T>& value) {
return convert(value.name, *(typename internal::TypeTraits<T>::Type*)(&value.value), value.bHas);
}

template<typename T>
JSONEncoder& convert(const char* sz, const T& value, bool* pHas = NULL) {
if (!pHas || (*pHas == true)) {
Expand Down
36 changes: 0 additions & 36 deletions include/struct2x/struct2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,6 @@
#define SERIALIZATION(...) \
EXPAND(MAKE_TAG_COUNT(SERIALIZATION, __VA_ARGS__, _4, _3, _2, _1)(__VA_ARGS__))

namespace struct2x {

template <typename VALUE> struct serializeItem {
serializeItem(const char *sz, uint32_t n, VALUE &v, bool *b)
: name(sz), num(n), value(v), type(0 /*TYPE_VARINT*/), bHas(b) {}
serializeItem(const char *sz, uint32_t n, VALUE &v, uint32_t t, bool *b)
: name(sz), num(n), value(v), type(t), bHas(b) {}

const char *name;
const uint32_t num;
VALUE &value;
const uint32_t type;
bool *bHas;

void setHas(bool b) { // proto2 has
if (bHas) *bHas = b;
}
void setValue(const VALUE &v) {
value = v;
setHas(true);
}
};

template <typename VALUE>
inline serializeItem<VALUE> makeItem(const char *sz, uint32_t num, VALUE &value, bool *b = NULL) {
return serializeItem<VALUE>(sz, num, value, b);
}

template <typename VALUE>
inline serializeItem<VALUE> makeItem(const char *sz, uint32_t num, VALUE &value, int32_t type,
bool *b = NULL) {
return serializeItem<VALUE>(sz, num, value, type, b);
}

} // namespace struct2x

#define EXPAND(args) args

#define MAKE_CALL(t, f) t.f
Expand Down

0 comments on commit b9c5e80

Please sign in to comment.