Skip to content

Commit

Permalink
Made things compile with compiler flags set.
Browse files Browse the repository at this point in the history
The code now compiles using compiler flags that check for basic C++
coding rules. One is still missing ( Wold-style-cast ) maybe we can fix
that one later.
  • Loading branch information
pibara committed Aug 13, 2011
1 parent c4fcc91 commit 8e7dc2b
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/lib) set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
set(includedir ${CMAKE_INSTALL_PREFIX}/include) set(includedir ${CMAKE_INSTALL_PREFIX}/include)
ADD_DEFINITIONS(-DUSE_GOBJECT_JSON_LIB -ggdb) ADD_DEFINITIONS( -Wall -Werror -Weffc++ -Wctor-dtor-privacy -Wuninitialized -Winit-self -Wmissing-include-dirs -Wfloat-equal -Wshadow -Wpointer-arith -Wunreachable-code )
ADD_DEFINITIONS(-DUSE_GOBJECT_JSON_LIB)
ADD_DEFINITIONS( -I/usr/include/json-glib-1.0/ -I/usr/include/glib-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/) ADD_DEFINITIONS( -I/usr/include/json-glib-1.0/ -I/usr/include/glib-2.0/ -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/)
add_library(jsonme SHARED JsonMeLib.cpp Scalar.cpp Node.cpp ParseError.cpp gobj/GobjectLibImpl.cpp gobj/GobjectImplParser.cpp gobj/GobjectImplFsTopNode.cpp gobj/GobjectImplStringTopNode.cpp gobj/GobjectImplError.cpp gobj/GobjectImplNode.cpp gobj/GobjectImplScalar.cpp gobj/GobjectImplKeys.cpp) add_library(jsonme SHARED JsonMeLib.cpp Scalar.cpp Node.cpp ParseError.cpp gobj/GobjectLibImpl.cpp gobj/GobjectImplParser.cpp gobj/GobjectImplFsTopNode.cpp gobj/GobjectImplStringTopNode.cpp gobj/GobjectImplError.cpp gobj/GobjectImplNode.cpp gobj/GobjectImplScalar.cpp gobj/GobjectImplKeys.cpp)
SET_TARGET_PROPERTIES(jsonme PROPERTIES VERSION 1.0.0 SOVERSION 1) SET_TARGET_PROPERTIES(jsonme PROPERTIES VERSION 1.0.0 SOVERSION 1)
Expand Down
1 change: 1 addition & 0 deletions Node.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace jsonme {
class NullNode: public AbstractNode { class NullNode: public AbstractNode {
NullKeys mNullKeys; NullKeys mNullKeys;
public: public:
NullNode():mNullKeys(){}
AbstractKeys & keys() { return mNullKeys;} AbstractKeys & keys() { return mNullKeys;}
jsonme::nodetype nodetype() const {return INVALID;} jsonme::nodetype nodetype() const {return INVALID;}
Node operator[](std::string const & name) const { return Node();} Node operator[](std::string const & name) const { return Node();}
Expand Down
7 changes: 4 additions & 3 deletions README
Original file line number Original file line Diff line number Diff line change
@@ -1,14 +1,15 @@
This library is a wrapper for the json-glib library that aims tp provide the user with a trivial alternative API to the API provided by the base json-glib library. This library is a wrapper for the json-glib library that aims tp provide the user with a trivial alternative API to the API provided by the base json-glib library.


This is the first version of the json-me (JSON made easy) that I created as a weekend project. This is an early version of the json-me (JSON made easy) project.

It has the following issues that I might fix in a later release. Given that I don't have much time to It has the following issues that I might fix in a later release. Given that I don't have much time to
work on project like this and given that my priorities lie with different projects, you may consider work on project like this and given that my priorities lie with different projects, you may consider
it as a wishlist that if you like this library would make me very happy if you could contribute it: it as a wishlist that if you like this library would make me very happy if you could contribute it:


* Write some decent tests.
* See if we can get stuff compiling with the -Wold-style-cast flag set.
* I didn't find a list of the Gtype's that json-glib can produce, there are probably some pieces of * I didn't find a list of the Gtype's that json-glib can produce, there are probably some pieces of
dead code in gobj/GobjectImplScalar.cpp and there might be one missing. dead code in gobj/GobjectImplScalar.cpp and there might be one missing.
* I didn't write any unit tests. All I wrote was a litle tiny program for a basic API test.
Given the limited test coverage, there may still be some bugs in this library.
* The CMakeLists.txt doesn't look for its dependencies and just adds -I flags that happen to be right * The CMakeLists.txt doesn't look for its dependencies and just adds -I flags that happen to be right
on Ubuntu 11.4. Should do some real checking. on Ubuntu 11.4. Should do some real checking.
* I didn't create non of the operator<< stuff for making usage ostream usage easy. Tried to for half * I didn't create non of the operator<< stuff for making usage ostream usage easy. Tried to for half
Expand Down
2 changes: 2 additions & 0 deletions gobj/GobjectImplError.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace jsonme {
namespace impl { namespace impl {
class GobjectImplError { class GobjectImplError {
GError *mError; GError *mError;
GobjectImplError(const GobjectImplError&);
GobjectImplError &operator=(const GobjectImplError&);
public: public:
GobjectImplError(); GobjectImplError();
~GobjectImplError(); ~GobjectImplError();
Expand Down
2 changes: 1 addition & 1 deletion gobj/GobjectImplFsTopNode.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "GobjectImplScalar.hpp" #include "GobjectImplScalar.hpp"
namespace jsonme { namespace jsonme {
namespace impl { namespace impl {
GobjectImplFsTopNode::GobjectImplFsTopNode(std::string const & path):mRoot(0) { GobjectImplFsTopNode::GobjectImplFsTopNode(std::string const & path):mParser(),mRoot(0) {
GobjectImplError lerror; GobjectImplError lerror;
json_parser_load_from_file (mParser,path.c_str(), lerror.errorp()); json_parser_load_from_file (mParser,path.c_str(), lerror.errorp());
if (lerror.error()) { if (lerror.error()) {
Expand Down
2 changes: 2 additions & 0 deletions gobj/GobjectImplFsTopNode.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace jsonme {
class GobjectImplFsTopNode: public jsonme::AbstractNode { class GobjectImplFsTopNode: public jsonme::AbstractNode {
GobjectImplParser mParser; GobjectImplParser mParser;
GobjectImplNode *mRoot; GobjectImplNode *mRoot;
GobjectImplFsTopNode(const GobjectImplFsTopNode&);
GobjectImplFsTopNode & operator=(const GobjectImplFsTopNode&);
public: public:
GobjectImplFsTopNode(std::string const & jsonstring); GobjectImplFsTopNode(std::string const & jsonstring);
~GobjectImplFsTopNode() throw(); ~GobjectImplFsTopNode() throw();
Expand Down
2 changes: 1 addition & 1 deletion gobj/GobjectImplKeys.cpp
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "GobjectImplKeys.hpp" #include "GobjectImplKeys.hpp"
namespace jsonme { namespace jsonme {
GobjectImplKeys::GobjectImplKeys(JsonNode* node) { GobjectImplKeys::GobjectImplKeys(JsonNode* node):mKeys() {
if (json_node_get_node_type(node) == JSON_NODE_OBJECT) { if (json_node_get_node_type(node) == JSON_NODE_OBJECT) {
JsonObject *asObject=json_node_get_object(node); JsonObject *asObject=json_node_get_object(node);
if (asObject) { if (asObject) {
Expand Down
2 changes: 2 additions & 0 deletions gobj/GobjectImplNode.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace jsonme {
class GobjectImplNode: public AbstractNode { class GobjectImplNode: public AbstractNode {
JsonNode * const mNode; JsonNode * const mNode;
GobjectImplKeys mKeys; GobjectImplKeys mKeys;
GobjectImplNode(const GobjectImplNode&);
GobjectImplNode &operator=(const GobjectImplNode&);
public: public:
GobjectImplNode(JsonNode * const node); GobjectImplNode(JsonNode * const node);
AbstractKeys &keys() { return mKeys;} AbstractKeys &keys() { return mKeys;}
Expand Down
2 changes: 2 additions & 0 deletions gobj/GobjectImplParser.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace jsonme {
namespace impl { namespace impl {
class GobjectImplParser { class GobjectImplParser {
JsonParser *mParser; JsonParser *mParser;
GobjectImplParser(const GobjectImplParser&);
GobjectImplParser & operator=(const GobjectImplParser&);
public: public:
GobjectImplParser(); GobjectImplParser();
~GobjectImplParser(); ~GobjectImplParser();
Expand Down
2 changes: 2 additions & 0 deletions gobj/GobjectImplScalar.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace jsonme {
class GobjectImplScalar: public AbstractScalar { class GobjectImplScalar: public AbstractScalar {
JsonNode * const mNode; JsonNode * const mNode;
GValue mValue; GValue mValue;
GobjectImplScalar(const GobjectImplScalar &);
GobjectImplScalar & operator=(const GobjectImplScalar&);
public: public:
GobjectImplScalar(JsonNode * const node); GobjectImplScalar(JsonNode * const node);
~GobjectImplScalar() throw(); ~GobjectImplScalar() throw();
Expand Down
2 changes: 1 addition & 1 deletion gobj/GobjectImplStringTopNode.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "GobjectImplScalar.hpp" #include "GobjectImplScalar.hpp"
namespace jsonme { namespace jsonme {
namespace impl { namespace impl {
GobjectImplStringTopNode::GobjectImplStringTopNode(std::string const & jsonstring):mRoot(0) { GobjectImplStringTopNode::GobjectImplStringTopNode(std::string const & jsonstring):mParser(),mRoot(0) {
GobjectImplError lerror; GobjectImplError lerror;
json_parser_load_from_data (mParser,jsonstring.c_str(),jsonstring.size(),lerror.errorp()); json_parser_load_from_data (mParser,jsonstring.c_str(),jsonstring.size(),lerror.errorp());
if (lerror.error()) { if (lerror.error()) {
Expand Down
2 changes: 2 additions & 0 deletions gobj/GobjectImplStringTopNode.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace jsonme {
class GobjectImplStringTopNode: public jsonme::AbstractNode { class GobjectImplStringTopNode: public jsonme::AbstractNode {
GobjectImplParser mParser; GobjectImplParser mParser;
GobjectImplNode * mRoot; GobjectImplNode * mRoot;
GobjectImplStringTopNode(const GobjectImplStringTopNode&);
GobjectImplStringTopNode & operator=(const GobjectImplStringTopNode&);
public: public:
GobjectImplStringTopNode(std::string const & jsonstring); GobjectImplStringTopNode(std::string const & jsonstring);
~GobjectImplStringTopNode() throw(); ~GobjectImplStringTopNode() throw();
Expand Down
6 changes: 3 additions & 3 deletions main.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc,char **argv) {
std::cerr << "No keys returned from routers." << std::endl;; std::cerr << "No keys returned from routers." << std::endl;;
return 1; return 1;
} }
for (int keyindex=0;keyindex < router.keys().size() ; keyindex++) { for (size_t keyindex=0;keyindex < router.keys().size() ; keyindex++) {
std::cerr << "keys[" << keyindex << "] : " << std::endl; std::cerr << "keys[" << keyindex << "] : " << std::endl;
jsonme::AbstractKeys &keys=router.keys(); jsonme::AbstractKeys &keys=router.keys();
std::string key=keys[keyindex]; std::string key=keys[keyindex];
Expand All @@ -44,8 +44,8 @@ int main(int argc,char **argv) {
std::cerr << "gateway: " << name << std::endl << "\tip\t:\t" << gip << std::endl << "\ttable\t:\t" << table << std::endl; std::cerr << "gateway: " << name << std::endl << "\tip\t:\t" << gip << std::endl << "\ttable\t:\t" << table << std::endl;
size_t groupcount=gateway["allowedgroups"].size(); size_t groupcount=gateway["allowedgroups"].size();
for (size_t index2=0; index2 < groupcount; index2++) { for (size_t index2=0; index2 < groupcount; index2++) {
std::string group=gateway["allowedgroups"][index2]; std::string group2=gateway["allowedgroups"][index2];
std::cerr << "\tgroup\t:\t" << group << std::endl; std::cerr << "\tgroup\t:\t" << group2 << std::endl;
} }
} }
return 0; return 0;
Expand Down

0 comments on commit 8e7dc2b

Please sign in to comment.