diff options
author | deva <deva> | 2008-06-09 06:49:58 +0000 |
---|---|---|
committer | deva <deva> | 2008-06-09 06:49:58 +0000 |
commit | e80ccdfac750fdd318eecb35b5f48a3d251ec7ec (patch) | |
tree | c296fb042d17f75aad06ff95e5f48dcb8143dabd /server/src/widgetgenerator.cc | |
parent | c3a7893d9f2c67614257bc0dbfa802b9cc9ff056 (diff) |
Made output accumulation in a buffer and write in the end, thus enabling the corretc outputting of the error box if neccessary.
Diffstat (limited to 'server/src/widgetgenerator.cc')
-rw-r--r-- | server/src/widgetgenerator.cc | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc index 6234513..43b202f 100644 --- a/server/src/widgetgenerator.cc +++ b/server/src/widgetgenerator.cc @@ -26,17 +26,18 @@ */ #include "widgetgenerator.h" -static void send_macro_widget(Macro ¯o, - Widget &widget, - TCPSocket &socket, - std::string tabs, - LUAQueryMapper &mapper, - Values &values) +static std::string send_macro_widget(Macro ¯o, + Widget &widget, + std::string tabs, + LUAQueryMapper &mapper, + Values &values) { + std::string result; + std::string prefilled; time_t timestamp = 0; - socket.write(tabs + "<" + widget.attributes["type"]); + result = tabs + "<" + widget.attributes["type"]; std::map< std::string, std::string >::iterator p = widget.attributes.begin(); // Check if the field has a map, and fill in the value if it has... @@ -72,26 +73,28 @@ static void send_macro_widget(Macro ¯o, while(p != widget.attributes.end()) { if(p->first != "type" && p->first != "map") { - socket.write(" " + p->first + "=\"" + p->second + "\""); + result += " " + p->first + "=\"" + p->second + "\""; } p++; } - if(prefilled != "") socket.write(" prefilled=\"" + prefilled + "\""); + if(prefilled != "") result += " prefilled=\"" + prefilled + "\""; if(widget.widgets.size() == 0) { // If node is empty, use short tag form - socket.write("/>\n"); - return; + result += "/>\n"; + return result; } - socket.write(">\n"); + result += ">\n"; std::vector< Widget >::iterator w = widget.widgets.begin(); while(w != widget.widgets.end()) { - send_macro_widget(macro, *w, socket, tabs + " ", mapper, values); + result += send_macro_widget(macro, *w, tabs + " ", mapper, values); w++; } - socket.write(tabs + "</" + widget.attributes["type"] + ">\n"); + result += tabs + "</" + widget.attributes["type"] + ">\n"; + + return result; } static void get_fields(Widget &widget, Fieldnames &fields) @@ -107,12 +110,12 @@ static void get_fields(Widget &widget, Fieldnames &fields) } } -void widgetgenerator(TCPSocket &socket, Macro ¯o, LUAQueryMapper &mapper, Database &db) +std::string widgetgenerator(Macro ¯o, LUAQueryMapper &mapper, Database &db) { Fieldnames fields; get_fields(macro.window, fields); Values values = db.getValues("2003791613", fields); - send_macro_widget(macro, macro.window, socket, " ", mapper, values); + return send_macro_widget(macro, macro.window, " ", mapper, values); } |