Permalink
Browse files

Reset Repository to clean.

    Refactoring code based on what I was learnt in version 1.
  • Loading branch information...
0 parents commit 9daf75acd1d1fb1815dc8c468a1689bf0e0c89fc @Loki-Astari committed Jan 25, 2015
Showing with 229 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +25 −0 .travis.yml
  4. +25 −0 COPYRIGHT
  5. +10 −0 Makefile
  6. +4 −0 Makefile.config
  7. +109 −0 README.md
  8. +6 −0 Serialize.cpp
  9. +1 −0 build
  10. +2 −0 third/.gitignore
  11. +37 −0 third/setup
@@ -0,0 +1,7 @@
+*.o
+unittest
+coverage/
+debug/
+release/
+profile/
+makefile_tmp
@@ -0,0 +1,3 @@
+[submodule "build"]
+ path = build
+ url = git@github.com:Loki-Astari/ThorMaker.git
@@ -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-*$/
+
@@ -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).
+
+
+
@@ -0,0 +1,10 @@
+
+THORSANVIL_ROOT = $(realpath ./)
+
+TARGET = Serialize.app
+
+include $(THORSANVIL_ROOT)/build/tools/Makefile
+
+
+
+
@@ -0,0 +1,4 @@
+
+CXXSTDVER = 14
+
+
@@ -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" } ]
+
+
+
+
+
+
+
@@ -0,0 +1,6 @@
+
+int main()
+{
+ // Fake program so Travis build still work
+}
+
Submodule build added at d2b9a7
@@ -0,0 +1,2 @@
+boost*
+gtest*
@@ -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.