Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef WAVEPACKET_DIALOG_REQUEST_H__
00033 #define WAVEPACKET_DIALOG_REQUEST_H__
00034
00035
00036 #include "common/common.h"
00037
00038 #include <sstream>
00039
00040
00041
00042 class Datahash;
00043
00044
00045 namespace dialog {
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 class ContainerRequest {
00070 public:
00071
00072 enum eAxis {
00073 eAxis_Horizontal = 1,
00074 eAxis_Vertical = 2
00075 };
00076
00077
00078 ContainerRequest(eAxis axis = eAxis_Vertical) : m_closed(false) {
00079 m_stream << "type container\n";
00080 m_stream << "axis ";
00081 m_stream << ((eAxis_Horizontal == axis) ? "h" : "v");
00082 m_stream << "\n";
00083 }
00084
00085
00086 std::string get(void) {
00087 this->close();
00088 return m_stream.str();
00089 }
00090
00091 smart_ptr<Datahash> getDatahash(void);
00092
00093 void addLabel(IN const char * label) {
00094 ASSERT(!m_closed, "request is closed");
00095 ASSERT(label, "null");
00096 m_stream << "element {\n";
00097 m_stream << "type label\n";
00098 m_stream << "value " << label << "\n";
00099 m_stream << "}\n";
00100 }
00101
00102 void addWidthString(IN const char * widthString) {
00103 ASSERT(!m_closed, "request is closed");
00104 ASSERT(widthString, "null");
00105 m_stream << "widthString " << widthString << "\n";
00106 }
00107
00108 void addButton(IN const char * submit, IN const char * label) {
00109 ASSERT(!m_closed, "request is closed");
00110 ASSERT(submit, "null");
00111 ASSERT(label, "null");
00112 m_stream << "element {\n";
00113 m_stream << "type button\n";
00114 m_stream << "submit " << submit << "\n";
00115 m_stream << "label " << label << "\n";
00116 m_stream << "}\n";
00117 }
00118
00119 void addTextbox(IN const char * name, IN const char * value,
00120 IN int max, IN bool encrypted = false) {
00121 ASSERT(!m_closed, "request is closed");
00122 ASSERT(name, "null");
00123 ASSERT(value, "null");
00124 ASSERT(max > 0, "Bad textbox max: %d", max);
00125 m_stream << "element {\n";
00126 m_stream << "type textbox\n";
00127 m_stream << "name " << name << "\n";
00128 m_stream << "value " << value << "\n";
00129 m_stream << "max " << max << "\n";
00130 if (encrypted) {
00131 m_stream << "encrypt true\n";
00132 }
00133 m_stream << "}\n";
00134 }
00135
00136 void addContainer(IN ContainerRequest& cr) {
00137 ASSERT(!m_closed, "request is closed");
00138 m_stream << "element {\n";
00139 m_stream << cr.get();
00140 m_stream << "}\n";
00141 }
00142
00143
00144 void addCustom(IN const char * string) {
00145 ASSERT(!m_closed, "request is closed");
00146 m_stream << string << "\n";
00147 }
00148 private:
00149
00150 void close(void) {
00151 if (!m_closed) {
00152 m_closed = true;
00153 }
00154 }
00155
00156
00157 bool m_closed;
00158 std::ostringstream m_stream;
00159 };
00160
00161
00162
00163 };
00164
00165 #endif // WAVEPACKET_DIALOG_REQUEST_H__
00166