summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/macro.h6
-rw-r--r--server/src/macro_parser.cc26
-rw-r--r--server/src/server.cc16
-rw-r--r--server/xml/commit.xml6
-rw-r--r--server/xml/example.xml20
-rw-r--r--server/xml/request.xml4
6 files changed, 51 insertions, 27 deletions
diff --git a/server/src/macro.h b/server/src/macro.h
index 2252d90..9d4692f 100644
--- a/server/src/macro.h
+++ b/server/src/macro.h
@@ -29,13 +29,17 @@
#include <string>
#include <vector>
+#include <map>
+/*
class WidgetProperty {
public:
std::string name;
std::string value;
};
-typedef std::vector< WidgetProperty > WidgetPropertyList;
+*/
+//typedef std::vector< WidgetProperty > WidgetPropertyList;
+typedef std::map< std::string, std::string > WidgetPropertyList;
class Widget;
typedef std::vector< Widget > WidgetList;
diff --git a/server/src/macro_parser.cc b/server/src/macro_parser.cc
index 62c74ca..9161613 100644
--- a/server/src/macro_parser.cc
+++ b/server/src/macro_parser.cc
@@ -70,13 +70,6 @@ static void start_hndl(void *p, const char *el, const char **attr)
// Do something reasonable with them...
- if(name == "macro") {
- // printf("Macro %s %s\n", attributes["name"].c_str(), attributes["resume"].c_str());
- parser->macro->name = attributes["name"];
- parser->macro->format = attributes["resume"];
- // return;
- }
-
if(name == "include") {
Macro inc;
@@ -91,6 +84,15 @@ static void start_hndl(void *p, const char *el, const char **attr)
return; // Don't do further parsing of this tag.
}
+ if(name == "macro") {
+
+ parser->macro->name = attributes["name"];
+ parser->macro->version = attributes["version"];
+ parser->macro->format = attributes["resume"];
+
+ return; // Don't do further parsing of this tag.
+ }
+
Widget widget;
widget.type = name;
@@ -107,11 +109,11 @@ static void start_hndl(void *p, const char *el, const char **attr)
std::map< std::string, std::string >::iterator i = attributes.begin();
while(i != attributes.end()) {
- WidgetProperty prop;
- prop.name = i->first;
- prop.value = i->second;
-
- wp->properties.push_back(prop);
+ // WidgetProperty prop;
+ // prop.name = i->first;
+ // prop.value = i->second;
+ // wp->properties.push_back(prop);
+ wp->properties[i->first] = i->second;
i++;
}
diff --git a/server/src/server.cc b/server/src/server.cc
index c88de4d..2a4c882 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -57,10 +57,15 @@ static void send_macro_widget(Widget &widget, TCPSocket &socket, std::string tab
socket.write(tabs + "<" + widget.type);
WidgetPropertyList::iterator p = widget.properties.begin();
while(p != widget.properties.end()) {
- WidgetProperty &property = *p;
- socket.write(" " + property.name + "=\"" + property.value + "\"");
+ socket.write(" " + p->first + "=\"" + p->second + "\"");
p++;
}
+
+ if(widget.widgets.size() == 0) { // If node is empty, use short tag form
+ socket.write("/>\n");
+ return;
+ }
+
socket.write(">\n");
WidgetList::iterator w = widget.widgets.begin();
@@ -91,11 +96,14 @@ static void connection(TCPSocket &socket)
Macro macro;
parse_macro(request.macro, macro);
+ socket.write(" <macro version=\"" + macro.version + "\" name=\""
+ + macro.name + "\" resume=\"" + macro.format + "\">\n");
WidgetList::iterator w = macro.widgets.begin();
while(w != macro.widgets.end()) {
- send_macro_widget(*w, socket, " ");
+ send_macro_widget(*w, socket, " ");
w++;
}
+ socket.write(" </macro>\n");
printf("done.\n");
@@ -125,8 +133,6 @@ static void connection(TCPSocket &socket)
journal_commit_addr.c_str(), journal_commit_port,
resume.c_str(), resume.length());
- // printf(resume.c_str());
-
i++;
}
}
diff --git a/server/xml/commit.xml b/server/xml/commit.xml
new file mode 100644
index 0000000..0e9ff86
--- /dev/null
+++ b/server/xml/commit.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<commit name="test_macro" cpr="1505050505" version="1.0">
+ <field name="visus_subjective" value="2.85"/>
+ <field name="visus_objective" value="2.91"/>
+ <field name="eye" value="osin"/>
+</commit>
diff --git a/server/xml/example.xml b/server/xml/example.xml
index 3273d71..b9974a8 100644
--- a/server/xml/example.xml
+++ b/server/xml/example.xml
@@ -8,37 +8,37 @@
layout="vbox">
<include name="patient"/>
<frame name="spl_frame" caption="Spl:" layout="vbox">
- <lineedit name="spl_note" regexp=".*" value="På begge sider alderssvarende forhold. Der er let katarakt, som dog ikke er operationskrævende."/>
+ <lineedit name="spl_note" regexp=".*" value="På begge sider alderssvarende forhold. Der er let katarakt, som dog ikke er operationskrævende." help="Hjælpenisse"/>
</frame>
<frame name="linse_frame" caption="Linser:" layout="vbox">
<frame name="linse_framea" layout="hbox">
<label name="a" width="300" caption="Linse1 er en lidt længere streng end de to andre:"/>
- <lineedit name="linse1" regexp="[0-9]{1,3}D" value="90K"/>
+ <lineedit name="linse1" regexp="[0-9]{1,3}D" value="90K" help="Hjælpenisse"/>
</frame>
<frame name="linse_frameb" layout="hbox">
<label name="b" width="300" caption="Linse2:"/>
- <lineedit name="linse2" regexp="[0-9]{1,3}D" value="90D"/>
+ <lineedit name="linse2" regexp="[0-9]{1,3}D" value="90D" help="Hjælpenisse"/>
</frame>
<frame name="linse_framec" layout="hbox">
<label name="c" width="300" caption="Linse3:"/>
- <lineedit name="linse3" regexp="[0-9]{1,3}D" value="90D"/>
+ <lineedit name="linse3" regexp="[0-9]{1,3}D" value="90D" help="Hjælpenisse"/>
</frame>
</frame>
<frame name="swelling_frame" layout="hbox">
<label name="swelling" caption="Der findes central hævelse med:"/>
<frame name="swelling_radios" layout="hbox">
- <radiobuttons name="radio" value="" layout="vbox">
+ <radiobuttons name="radio" value="" layout="vbox" help="Hjælpenisse">
<item caption="Radio Randblødning" value="rand"/>
<item caption="Radio Exsudater" value="exsudater"/>
<item caption="Radio Blahblah" value="blabla"/>
</radiobuttons>
- <combobox name="combo" value="fiskesuppe">
+ <combobox name="combo" value="fiskesuppe" help="Hjælpenisse">
<item caption="Combo Randblødning" value="rand"/>
<item caption="Combo Exsudater" value="exsudater"/>
<item caption="Combo Blahblah" value="blabla"/>
<item caption="Combo Blahblah" value="fisk"/>
</combobox>
- <listbox name="list" value="exsudate">
+ <listbox name="list" value="exsudate" help="Hjælpenisse">
<item caption="List Randblødning" value="rand"/>
<item caption="List Exsudater" value="exsudater"/>
<item caption="List Blahblah" value="blabla"/>
@@ -46,8 +46,10 @@
</frame>
</frame>
<frame name="buttons" layout="hbox">
- <button name="cancel" caption="Annuller" action="cancel"/>
- <button name="commit" caption="Godkend" action="commit"/>
+ <lineedit name="next_macro" regexp="[a-z_]+[a-z_0-9]*" value="example"/>
+ <button name="cancel" caption="Annuller" action="cancel" help="Hjælpenisse"/>
+ <button name="continue" caption="Fortsæt" action="continue" field="next_macro" help="Hjælpenisse"/>
+ <button name="commit" caption="Godkend" action="commit" help="Hjælpenisse"/>
</frame>
</window>
</macro>
diff --git a/server/xml/request.xml b/server/xml/request.xml
new file mode 100644
index 0000000..369d5ea
--- /dev/null
+++ b/server/xml/request.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<request cpr="1505050505" version="1.0">
+ <macro name="example"/>
+</request>