Skip to content

Commit

Permalink
Reset Repository to clean.
Browse files Browse the repository at this point in the history
    Refactoring code based on what I was learnt in version 1.
  • Loading branch information
Loki-Astari committed Jan 25, 2015
0 parents commit 9daf75a
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.o
unittest
coverage/
debug/
release/
profile/
makefile_tmp
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "build"]
path = build
url = git@github.com:Loki-Astari/ThorMaker.git
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
git:
submodules: false
language: cpp
os:
- linux
- osx
compiler:
- gcc
- clang
before_install:
- mv .gitmodules gitmodules.old
- sed -e 's#git@\([^:]*\):#https://\1/#' gitmodules.old > .gitmodules
- rm gitmodules.old
install:
- pushd third
- ./setup
- popd
script:
- make
branches:
only:
- master
- /^feature-*$/
- /^version-*$/

25 changes: 25 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


This software is "Public Domain"
(i.e. I freely give up my rights for the public good).

Notes:

You are free to use this in any code (private/commercial/open source) you like
without fees.

If you want to credit me as the original author I am happy for any links
back to this git hub project (but it is not required).



10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

THORSANVIL_ROOT = $(realpath ./)

TARGET = Serialize.app

include $(THORSANVIL_ROOT)/build/tools/Makefile




4 changes: 4 additions & 0 deletions Makefile.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

CXXSTDVER = 14


109 changes: 109 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[![endorse](http://api.coderwall.com/lokiastari/endorsecount.png)](http://coderwall.com/lokiastari)
[![Build Status](https://travis-ci.org/Loki-Astari/ThorsSerializer.svg?branch=master)](https://travis-ci.org/Loki-Astari/ThorsSerializer)


Yet another JSON serialization library for C++

###Objective:

The objective is to make serialization/de-serialization of C++ object to/from
JSON trivial.

This means:
1) does not build a JSON object. Reads data directly into C++ object.
2) In normal usage there should be NO need to write any code.
3) User should not need to understand JSON or validate its input.
4) Should work seamlessly with streams.
5) Standard containers should automatically work

I am not concerned about speed.
Though my trivial test work just fine in terms of speed.

The design was done with the primary goal of communicating with WEB-Servers
that speak JSON. The main envisioned usage was for mobile devices were many
small JSON objects are transfered in both directions.

###Example Usage with ThorsStream

https://gist.github.com/Loki-Astari/8201956

###Build instructions (SIMPLE)

make -f MakeSimple
# Note this build a Serialize.a library
# No tests are run and no coverage test are done.
# The serialize library are mostly header files so you will still need these
# to include these from your own files.

###Building Notes:
This project can also use ThorMaker (which is just a set of makefiles) to build
This not only builds the code but runs unit tests and checks the code coverage of the unit tests.

Build instructions:
###################

# Set up required 3rd party libraries boost/gtest
cd third
./setup


# The following builds the Json parser and installs the
# release and debug libraries into build/lib and external headers into build/include
cd ../Json
make install

# The following builds the Serialization libs and installs the
# release and debug libraries into build/lib and external headers into build/include
cd ../Serialize
make install


###Example: C++11 (see code in test.cpp for full code)

/* A class that you want to serialize. */
class MyClass
{
int data1;
float data2;
std::string data3;

// This is only required if the members are private.
friend struct ThorsAnvil::Serialize::Json::JsonSerializeTraits<MyClass>;
};


/*
* Though there is no code involved, you do need to set up
* this structure to tell the library what fields need to be serialized.
* To do this use the macro: JsonSerializeTraits_MAKE()
* Specifying parents to serialize(or void), your class, a list of members to serialize.
*/
JsonSerializeTraits_MAKE(void, MyClass, data1, data2, data3)

This allows us to import and export object of the above class really easily.

MyCLass data;
data.data1 = 56;
data.data2 = 23.456;
data.data3 = "Hi there";

std::cout << ThorsAnvil::Serializer::jsonExport(data) << "\n";

This generates:

{"data1": 56 ,"data2": 23.456 ,"data3": "Hi there" }

It will also handle all standard containers automaticaly:

std::vector<MyClass> vec(4, data);
std::cout << ThorsAnvil::Serializer::jsonExport(vec) << "\n";

// Results in:
[{"data1": 56 ,"data2": 23.456 ,"data3": "Hi there" }, {"data1": 56 ,"data2": 23.456 ,"data3": "Hi there" }, {"data1": 56 ,"data2": 23.456 ,"data3": "Hi there" }, {"data1": 56 ,"data2": 23.456 ,"data3": "Hi there" } ]







6 changes: 6 additions & 0 deletions Serialize.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

int main()
{
// Fake program so Travis build still work
}

1 change: 1 addition & 0 deletions build
Submodule build added at d2b9a7
2 changes: 2 additions & 0 deletions third/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
boost*
gtest*
37 changes: 37 additions & 0 deletions third/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

#
# Change this as required to point at the root of ThorsAnvil code
ROOT=$(pwd)
THORSANVIL_ROOT=$(dirname ${ROOT})

pushd ${THORSANVIL_ROOT}
git submodule init
git submodule update
cd build/third
./setup
popd


install="sudo apt-get --yes"
check="list"

host=`uname`
if [[ "${host}" == "Darwin" ]]; then
# This is a mac use brew
install="brew"
check="brew"
fi

if [[ "${host}" == "Linux" ]]; then
${install} install libboost-dev
${install} install libboost-doc
fi
if [[ "${host}" == "Darwin" ]]; then
${check} list boost >/dev/null 2>&1 || { echo >&2 "boost required but not install. Will attempt to install"; exit 1; }
if [[ $? == 1 ]]; then
${install} install boost
fi
fi


0 comments on commit 9daf75a

Please sign in to comment.