summaryrefslogtreecommitdiff
path: root/project2/json
diff options
context:
space:
mode:
Diffstat (limited to 'project2/json')
-rw-r--r--project2/json/presenter.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/project2/json/presenter.cpp b/project2/json/presenter.cpp
index 3b069a4..aaa72bf 100644
--- a/project2/json/presenter.cpp
+++ b/project2/json/presenter.cpp
@@ -5,10 +5,13 @@
#include "transform.h"
#include <stack>
-class JsonPresenter : public MultiRowSetPresenter, public ContentPresenter, public SourceOf<json::Object> {
+class JsonPresenter : public MultiRowSetPresenter, public ContentPresenter, public SourceOf<json::Object>, public WritableContent, public SourceOf<WritableContent> {
public:
- JsonPresenter(ScriptNodePtr) :
- ContentPresenter("application/json; charset=UTF-8") {
+ JsonPresenter(ScriptNodePtr s) :
+ TransformSource(s),
+ ContentPresenter("application/json; charset=UTF-8"),
+ SourceOf<json::Object>(s),
+ SourceOf<WritableContent>(s) {
curRowSet.push(&object);
}
void addNamedValue(const Glib::ustring & name, const VariableType & value) const {
@@ -43,6 +46,17 @@ class JsonPresenter : public MultiRowSetPresenter, public ContentPresenter, publ
operator const json::Object *() const {
return &object;
}
+ operator const WritableContent * () const
+ {
+ return this;
+ }
+ Glib::ustring getContentType() const {
+ return contentType;
+ }
+ void writeTo(std::ostream & o) const {
+ serializeObject(object, o);
+ }
+
private:
mutable json::Object object;
mutable std::stack<json::Object *> curRowSet;