Permalink
Browse files

Made things compile with compiler flags set.

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...
1 parent c4fcc91 commit 8e7dc2bd066ef86b2a6d899220e8c287d643d90c @pibara committed Aug 13, 2011
View
@@ -5,7 +5,8 @@ set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
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_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)
View
@@ -4,6 +4,7 @@ namespace jsonme {
class NullNode: public AbstractNode {
NullKeys mNullKeys;
public:
+ NullNode():mNullKeys(){}
AbstractKeys & keys() { return mNullKeys;}
jsonme::nodetype nodetype() const {return INVALID;}
Node operator[](std::string const & name) const { return Node();}
View
7 README
@@ -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 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
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:
+* 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
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
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
@@ -5,6 +5,8 @@ namespace jsonme {
namespace impl {
class GobjectImplError {
GError *mError;
+ GobjectImplError(const GobjectImplError&);
+ GobjectImplError &operator=(const GobjectImplError&);
public:
GobjectImplError();
~GobjectImplError();
@@ -4,7 +4,7 @@
#include "GobjectImplScalar.hpp"
namespace jsonme {
namespace impl {
- GobjectImplFsTopNode::GobjectImplFsTopNode(std::string const & path):mRoot(0) {
+ GobjectImplFsTopNode::GobjectImplFsTopNode(std::string const & path):mParser(),mRoot(0) {
GobjectImplError lerror;
json_parser_load_from_file (mParser,path.c_str(), lerror.errorp());
if (lerror.error()) {
@@ -8,6 +8,8 @@ namespace jsonme {
class GobjectImplFsTopNode: public jsonme::AbstractNode {
GobjectImplParser mParser;
GobjectImplNode *mRoot;
+ GobjectImplFsTopNode(const GobjectImplFsTopNode&);
+ GobjectImplFsTopNode & operator=(const GobjectImplFsTopNode&);
public:
GobjectImplFsTopNode(std::string const & jsonstring);
~GobjectImplFsTopNode() throw();
View
@@ -1,6 +1,6 @@
#include "GobjectImplKeys.hpp"
namespace jsonme {
- GobjectImplKeys::GobjectImplKeys(JsonNode* node) {
+ GobjectImplKeys::GobjectImplKeys(JsonNode* node):mKeys() {
if (json_node_get_node_type(node) == JSON_NODE_OBJECT) {
JsonObject *asObject=json_node_get_object(node);
if (asObject) {
View
@@ -9,6 +9,8 @@ namespace jsonme {
class GobjectImplNode: public AbstractNode {
JsonNode * const mNode;
GobjectImplKeys mKeys;
+ GobjectImplNode(const GobjectImplNode&);
+ GobjectImplNode &operator=(const GobjectImplNode&);
public:
GobjectImplNode(JsonNode * const node);
AbstractKeys &keys() { return mKeys;}
@@ -6,6 +6,8 @@ namespace jsonme {
namespace impl {
class GobjectImplParser {
JsonParser *mParser;
+ GobjectImplParser(const GobjectImplParser&);
+ GobjectImplParser & operator=(const GobjectImplParser&);
public:
GobjectImplParser();
~GobjectImplParser();
@@ -8,6 +8,8 @@ namespace jsonme {
class GobjectImplScalar: public AbstractScalar {
JsonNode * const mNode;
GValue mValue;
+ GobjectImplScalar(const GobjectImplScalar &);
+ GobjectImplScalar & operator=(const GobjectImplScalar&);
public:
GobjectImplScalar(JsonNode * const node);
~GobjectImplScalar() throw();
@@ -4,7 +4,7 @@
#include "GobjectImplScalar.hpp"
namespace jsonme {
namespace impl {
- GobjectImplStringTopNode::GobjectImplStringTopNode(std::string const & jsonstring):mRoot(0) {
+ GobjectImplStringTopNode::GobjectImplStringTopNode(std::string const & jsonstring):mParser(),mRoot(0) {
GobjectImplError lerror;
json_parser_load_from_data (mParser,jsonstring.c_str(),jsonstring.size(),lerror.errorp());
if (lerror.error()) {
@@ -9,6 +9,8 @@ namespace jsonme {
class GobjectImplStringTopNode: public jsonme::AbstractNode {
GobjectImplParser mParser;
GobjectImplNode * mRoot;
+ GobjectImplStringTopNode(const GobjectImplStringTopNode&);
+ GobjectImplStringTopNode & operator=(const GobjectImplStringTopNode&);
public:
GobjectImplStringTopNode(std::string const & jsonstring);
~GobjectImplStringTopNode() throw();
View
@@ -21,7 +21,7 @@ int main(int argc,char **argv) {
std::cerr << "No keys returned from routers." << std::endl;;
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;
jsonme::AbstractKeys &keys=router.keys();
std::string key=keys[keyindex];
@@ -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;
size_t groupcount=gateway["allowedgroups"].size();
for (size_t index2=0; index2 < groupcount; index2++) {
- std::string group=gateway["allowedgroups"][index2];
- std::cerr << "\tgroup\t:\t" << group << std::endl;
+ std::string group2=gateway["allowedgroups"][index2];
+ std::cerr << "\tgroup\t:\t" << group2 << std::endl;
}
}
return 0;

0 comments on commit 8e7dc2b

Please sign in to comment.