Skip to content

Commit

Permalink
Add Qtx namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Jan 11, 2013
1 parent 613c216 commit 41b11c4
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/QtxJson
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef QTXJSON_MODULE_H
#define QTXJSON_MODULE_H

#include "../src/json/jsonglobal.h"
#include "../src/json/jsonreader.h"
#include "../src/json/jsonstreamreader.h"
#include "../src/json/jsonstreamwriter.h"
Expand Down
17 changes: 17 additions & 0 deletions src/json/jsonglobal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef QTXJSON_GLOBAL_H
#define QTXJSON_GLOBAL_H

#ifndef QTX_NAMESPACE
# define QTX_NAMESPACE Qtx
#endif
#ifndef QTX_USE_NAMESPACE
# define QTX_USE_NAMESPACE using namespace ::QTX_NAMESPACE;
#endif
#ifndef QTX_BEGIN_NAMESPACE
# define QTX_BEGIN_NAMESPACE namespace QTX_NAMESPACE {
#endif
#ifndef QTX_END_NAMESPACE
# define QTX_END_NAMESPACE }
#endif

#endif /* QTXJSON_GLOBAL_H */
5 changes: 5 additions & 0 deletions src/json/jsonreader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "jsonreader.h"

QTX_BEGIN_NAMESPACE


QHash<QString, QVariant> JsonReader::parse(const QByteArray & data)
{
Expand Down Expand Up @@ -248,3 +250,6 @@ bool JsonReaderContext::add(const QString & key, const QVariant & value)

return false;
}


QTX_END_NAMESPACE
6 changes: 6 additions & 0 deletions src/json/jsonreader.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef JSONREADER_H
#define JSONREADER_H

#include "jsonglobal.h"
#include <QtCore>
#include "jsonstreamreader.h"

QTX_BEGIN_NAMESPACE


class JsonReaderContext;

Expand Down Expand Up @@ -80,4 +83,7 @@ class JsonReaderContext
QList<QVariant> mArray;
};


QTX_END_NAMESPACE

#endif // JSONREADER_H
5 changes: 5 additions & 0 deletions src/json/jsonstreamreader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "jsonstreamreader.h"

QTX_BEGIN_NAMESPACE


static yajl_callbacks callbacks = {
json_parse_null,
Expand Down Expand Up @@ -192,3 +194,6 @@ int json_parse_end_array(void * ctx)
reader->enqueueToken(JsonStreamReader::EndArray);
return 1;
}


QTX_END_NAMESPACE
6 changes: 6 additions & 0 deletions src/json/jsonstreamreader.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef JSONSTREAMREADER_H
#define JSONSTREAMREADER_H

#include "jsonglobal.h"
#include <QtCore>
#include <yajl/yajl_parse.h>

QTX_BEGIN_NAMESPACE


extern int json_parse_null(void * ctx);
extern int json_parse_boolean(void * ctx, int boolean);
Expand Down Expand Up @@ -79,4 +82,7 @@ class JsonStreamReader
friend int json_parse_end_array(void * ctx);
};


QTX_END_NAMESPACE

#endif // JSONSTREAMREADER_H
5 changes: 5 additions & 0 deletions src/json/jsonstreamwriter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "jsonstreamwriter.h"

QTX_BEGIN_NAMESPACE


JsonStreamWriter::JsonStreamWriter()
{
Expand Down Expand Up @@ -77,3 +79,6 @@ QByteArray JsonStreamWriter::data()

//yajl_gen_clear(g);
}


QTX_END_NAMESPACE
6 changes: 6 additions & 0 deletions src/json/jsonstreamwriter.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef JSONSTREAMWRITER_H
#define JSONSTREAMWRITER_H

#include "jsonglobal.h"
#include <QtCore>
#include <yajl/yajl_gen.h>

QTX_BEGIN_NAMESPACE


class JsonStreamWriter
{
Expand All @@ -28,4 +31,7 @@ class JsonStreamWriter
yajl_gen mGenerator;
};


QTX_END_NAMESPACE

#endif // JSONSTREAMWRITER_H
5 changes: 5 additions & 0 deletions src/json/jsonwriter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "jsonwriter.h"

QTX_BEGIN_NAMESPACE


QString JsonWriter::stringify(const QHash<QString, QVariant> & object)
{
Expand Down Expand Up @@ -87,3 +89,6 @@ void JsonWriter::writeArray(const QList<QVariant> & array)

mWriter.writeEndArray();
}


QTX_END_NAMESPACE
6 changes: 6 additions & 0 deletions src/json/jsonwriter.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef JSONWRITER_H
#define JSONWRITER_H

#include "jsonglobal.h"
#include <QtCore>
#include "jsonstreamwriter.h"

QTX_BEGIN_NAMESPACE


class JsonWriter
{
Expand All @@ -25,4 +28,7 @@ class JsonWriter
JsonStreamWriter mWriter;
};


QTX_END_NAMESPACE

#endif // JSONWRITER_H

0 comments on commit 41b11c4

Please sign in to comment.