Skip to content

Commit

Permalink
Change version number
Browse files Browse the repository at this point in the history
  • Loading branch information
brunexgeek committed Nov 1, 2021
1 parent 4a8bf8b commit 35f21dc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.8)

set(PROTOGEN_MAJOR 2)
set(PROTOGEN_MINOR 0)
set(PROTOGEN_PATCH 0)
set(PROTOGEN_PATCH 1)

add_definitions(-DPROTOGEN_MAJOR=${PROTOGEN_MAJOR})
add_definitions(-DPROTOGEN_MINOR=${PROTOGEN_MINOR})
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PG_JSON(MyData, name, age, pets)
Now it's possible to serialize and deserialize the type using the functions ``serialize`` and ``deserialize``.
```c++
using protogen_2_0_0;
using protogen_2_0_1;
MyData obj;
obj.name = "Margot";
Expand Down Expand Up @@ -113,7 +113,7 @@ Types generated by protogen compiler contain helper functions like ``serialize``
These options can be set in the proto3 file:

* **obfuscate_strings** (top-level) – Enable string obfuscation. If enabled, all strings in the C++ generated file will be obfuscated with a very simple (and insecure) algorithm. The default value is `false`. This option can be used to make a little difficult for curious people to find out your JSON field names by inspecting binary files.
* **number_names** (top-level) – Use field numbers as JSON field names. The default value is `false`. If enabled, every JSON field name will be the number of the corresponding field in the `.proto` file. This can reduce significantly the size of the JSON output.
* **number_names** (top-level) – Use field numbers as JSON field names. The default value is `false`. If enabled, every JSON field name will be the number of the corresponding field in the `.proto` file. This can significantly reduce the size of the JSON output.
* **transient** (field-level) – Make the field transient (`true`) or not (`false`). Transient fields are not serialized/deserialized. The default value is `false`.
* **cpp_use_lists** (top-level) – Use `std::list` (`true`) instead of `std::vector` (`false`) in repeated fields. This gives best performance if your program constantly changes repeated fields (add and/or remove items). This option does not affect `bytes` fields which always use `std::vector`. The default value is `false`.

Expand Down
6 changes: 3 additions & 3 deletions compiler/cpp/code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@


--- CODE_JSON_MODEL
namespace protogen_2_0_0 {
namespace protogen_2_0_1 {
template<> struct json<$1$>
{
static int read( json_context &ctx, $1$ &value ) { return read_object(ctx, value); }
Expand Down Expand Up @@ -118,9 +118,9 @@ $8$ return false;
------

--- CODE_ENTITY
PG_ENTITY($1$,$2$,protogen_2_0_0::json<$2$>)
PG_ENTITY($1$,$2$,protogen_2_0_1::json<$2$>)
------

--- CODE_ENTITY_JSON
PG_ENTITY_SERIALIZER($1$,$2$,protogen_2_0_0::json<$2$>)
PG_ENTITY_SERIALIZER($1$,$2$,protogen_2_0_1::json<$2$>)
------
56 changes: 28 additions & 28 deletions protogen.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef PROTOGEN_2_0_0
#define PROTOGEN_2_0_0
#ifndef PROTOGEN_2_0_1
#define PROTOGEN_2_0_1

#include <string>
#include <vector>
Expand All @@ -11,7 +11,7 @@

#define PG_MKSTR(...) #__VA_ARGS__

namespace protogen_2_0_0 {
namespace protogen_2_0_1 {

enum error_code
{
Expand Down Expand Up @@ -466,7 +466,7 @@ class mem_iterator

} // namespace internal

using namespace protogen_2_0_0::internal;
using namespace protogen_2_0_1::internal;

template<typename T, typename _ = void>
struct is_container : std::false_type {};
Expand Down Expand Up @@ -969,7 +969,7 @@ static int read_object( json_context &ctx, T &object )

#define PG_DIF_EX(field_id, field_name, field_label) \
if (name == field_label) { \
int result = protogen_2_0_0::json<decltype(value.field_name)>::read(ctx, value.field_name); \
int result = protogen_2_0_1::json<decltype(value.field_name)>::read(ctx, value.field_name); \
if (result == PGR_OK) ctx.mask |= (1 << field_id); \
return result; \
} else
Expand All @@ -978,34 +978,34 @@ static int read_object( json_context &ctx, T &object )
PG_DIF_EX(field_id, field_name, PG_MKSTR(field_name) )

#define PG_SIF_EX(field_name, field_label) \
if (!protogen_2_0_0::json<decltype(value.field_name)>::empty(value.field_name)) \
if (!protogen_2_0_1::json<decltype(value.field_name)>::empty(value.field_name)) \
{ \
if (!first) (*ctx.os) << ','; \
first = false; \
(*ctx.os) << '\"' << field_label << "\":"; \
protogen_2_0_0::json<decltype(value.field_name)>::write(ctx, value.field_name); \
protogen_2_0_1::json<decltype(value.field_name)>::write(ctx, value.field_name); \
}

#define PG_SIF(field_name,user_data,field_id) \
PG_SIF_EX(field_name, PG_MKSTR(field_name) )

#define PG_EIF(field_name,user_data,field_id) \
if (!protogen_2_0_0::json<decltype(value.field_name)>::empty(value.field_name)) return false;
if (!protogen_2_0_1::json<decltype(value.field_name)>::empty(value.field_name)) return false;

#define PG_CLL(field_name,user_data,field_id) \
protogen_2_0_0::json<decltype(value.field_name)>::clear(value.field_name);
protogen_2_0_1::json<decltype(value.field_name)>::clear(value.field_name);

#define PG_QIF(field_name,user_data,field_id) \
if (!protogen_2_0_0::json<decltype(a.field_name)>::equal(a.field_name, b.field_name)) return false;
if (!protogen_2_0_1::json<decltype(a.field_name)>::equal(a.field_name, b.field_name)) return false;

#define PG_SLL(field_name,user_data,field_id) \
protogen_2_0_0::json<decltype(a.field_name)>::swap(a.field_name, b.field_name);
protogen_2_0_1::json<decltype(a.field_name)>::swap(a.field_name, b.field_name);

#define PG_MIF(field_name,user_data,field_id) \
if (!(ctx.mask & (1 << field_id))) { name = PG_MKSTR(field_name); } else

#define PG_JSON(type, ...) \
namespace protogen_2_0_0 { \
namespace protogen_2_0_1 { \
template<> \
struct json<type> \
{ \
Expand Down Expand Up @@ -1053,7 +1053,7 @@ static int read_object( json_context &ctx, T &object )
};}

template<typename T>
bool deserialize( T &value, protogen_2_0_0::tokenizer& tok, bool required = false, ErrorInfo *err = nullptr )
bool deserialize( T &value, protogen_2_0_1::tokenizer& tok, bool required = false, ErrorInfo *err = nullptr )
{
json_context ctx;
ctx.tok = &tok;
Expand Down Expand Up @@ -1141,10 +1141,10 @@ void serialize( const T &value, std::ostream &out )
serialize<T>(value, os);
}

template<typename T, typename J = protogen_2_0_0::json<T>>
template<typename T, typename J = protogen_2_0_1::json<T>>
void clear( T &value ) { json<T>::clear(value); }

template<typename T, typename J = protogen_2_0_0::json<T>>
template<typename T, typename J = protogen_2_0_1::json<T>>
bool empty( const T &value ) { return json<T>::empty(value); }

// parent class for messages
Expand Down Expand Up @@ -1218,31 +1218,31 @@ struct message
};

#define PG_ENTITY(N,O,S) \
struct N : public O, public protogen_2_0_0::message< O, S > \
struct N : public O, public protogen_2_0_1::message< O, S > \
{ \
typedef O value_type; \
typedef S serializer_type; \
typedef protogen_2_0_0::ErrorInfo ErrorInfo; \
typedef protogen_2_0_1::ErrorInfo ErrorInfo; \
N() = default; \
N( const N& ) = default; \
N( N &&that ) { S::swap(*this, that); } \
N &operator=( const N & ) = default; \
using protogen_2_0_0::message<O, S>::serialize; \
using protogen_2_0_0::message<O, S>::deserialize; \
bool deserialize( protogen_2_0_0::tokenizer& tok, bool required = false, \
protogen_2_0_0::ErrorInfo *err = nullptr ) override \
using protogen_2_0_1::message<O, S>::serialize; \
using protogen_2_0_1::message<O, S>::deserialize; \
bool deserialize( protogen_2_0_1::tokenizer& tok, bool required = false, \
protogen_2_0_1::ErrorInfo *err = nullptr ) override \
{ \
protogen_2_0_0::json_context ctx; \
protogen_2_0_1::json_context ctx; \
ctx.tok = &tok; \
ctx.required = required; \
int result = S::read(ctx, *this); \
if (result == protogen_2_0_0::PGR_OK) return true; \
if (result == protogen_2_0_1::PGR_OK) return true; \
if (err != nullptr) *err = tok.error(); \
return false; \
} \
void serialize( protogen_2_0_0::ostream &out ) const override \
void serialize( protogen_2_0_1::ostream &out ) const override \
{ \
protogen_2_0_0::json_context ctx; \
protogen_2_0_1::json_context ctx; \
ctx.os = &out; \
S::write(ctx, *this); \
} \
Expand All @@ -1253,7 +1253,7 @@ struct message
};

#define PG_ENTITY_SERIALIZER(N,O,S) \
namespace protogen_2_0_0 { \
namespace protogen_2_0_1 { \
template<> \
struct json<N> \
{ \
Expand All @@ -1267,7 +1267,7 @@ struct message
static bool is_missing( json_context &ctx ) { return S::is_missing(ctx); } \
};}

} // namespace protogen_2_0_0
} // namespace protogen_2_0_1


#endif // PROTOGEN_2_0_0
#endif // PROTOGEN_2_0_1
2 changes: 1 addition & 1 deletion tests/tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Person

PG_JSON(compact::Person, name, age, gender, email, friends)

using namespace protogen_2_0_0;
using namespace protogen_2_0_1;

bool RUN_TEST1( int argc, char **argv)
{
Expand Down

0 comments on commit 35f21dc

Please sign in to comment.