PACK WOC  $VERSION$
proctrans.h
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 by Konrad Rosenbaum <konrad@silmor.de>
2 // protected under the GNU GPL version 3 or at your option any newer.
3 // See COPYING.GPL file that comes with this distribution.
4 //
5 
6 #ifndef WOC_PROCESSOR_TRANS_H
7 #define WOC_PROCESSOR_TRANS_H
8 
9 #include <QList>
10 #include <QMap>
11 #include <QObject>
12 #include <QPair>
13 #include <QStringList>
14 
17 {
18  public:
20  WocTransaction(const QDomElement&);
22  bool isValid()const{return m_valid;}
23 
25  QString name()const{return m_name;}
26 
28  bool hasInput(QString v)const;
30  QStringList inputNames()const;
32  QString inputType(QString)const;
33 
35  bool hasOutput(QString v)const;
37  QStringList outputNames()const;
39  QString outputType(QString)const;
40 
42  bool hasCall(QString c)const{return m_call.contains(c);}
44  QString callFunction(QString c)const{return m_call[c].first;}
46  QString callInclude(QString c)const{return m_call[c].second.trimmed();}
47 
49  enum AuthMode {
56  };
57  AuthMode authMode()const{return m_mode;}
58 
60  enum NoLogMode {
62  LogAll=0,
69  };
70  NoLogMode logMode()const{return m_logmode;}
71 
73  static bool isListType(QString t){return t.startsWith("List:");}
75  static QString plainType(QString t){
76  if(t.startsWith("List:"))t=t.mid(5);
77  QStringList l=t.split("/",QString::SkipEmptyParts);
78  if(l.size()>0)t=l[0];else t="unknown";
79  return t;
80  }
82  QString typeSerializer(QString t)const{
83  QStringList l=t.split("/",QString::SkipEmptyParts);
84  if(l.size()>1)return l[1];
85  else return "";
86  }
88  static bool isIntType(QString t){QString pt=plainType(t);return pt=="int" || pt=="int32" || pt=="int64";}
90  static bool isBoolType(QString t){return plainType(t)=="bool";}
92  static bool isStringType(QString t){QString p=plainType(t);return p=="astring"||p=="string";}
94  static bool isBlobType(QString t){QString p=plainType(t);return p=="blob";}
96  static bool isAttributeType(QString t){return t=="astring"||t=="int"||t=="int32"||t=="int64"||t=="bool";}
98  static bool isElementType(QString t){return !isAttributeType(t);}
100  static bool isObjectType(QString t){QString p=plainType(t);return p!="astring"&&p!="string"&&p!="int"&&p!="int32"&&p!="int64"&&p!="bool"&&p!="blob";}
101 
103  QStringList docStrings()const{return m_docstrings;}
105  QString inputDoc(QString v)const
106  {if(m_indoc.contains(v))return m_indoc[v];else return "";}
108  QString outputDoc(QString v)const
109  {if(m_outdoc.contains(v))return m_outdoc[v];else return "";}
111  QString privilegeDoc(QString p)const
112  {if(m_privdoc.contains(p))return m_privdoc[p];else return "";}
113 
115  QStringList privileges()const{return m_privileges;}
116 
118  bool isDbUpdating()const{return m_update;}
119  private:
120  QString m_name;
124  QMap<QString,QPair<QString,QString> > m_call;
125  QList<QPair<QString,QString> >m_input,m_output;
126  QStringList m_privileges;
127  //docu
128  QStringList m_docstrings;
129  QMap<QString,QString>m_indoc,m_outdoc,m_privdoc;
130 };
131 
132 #endif
QString callFunction(QString c) const
returns the called function
Definition: proctrans.h:44
QMap< QString, QString > m_privdoc
Definition: proctrans.h:129
QMap< QString, QString > m_indoc
Definition: proctrans.h:129
QStringList outputNames() const
returns the names of all outputs in the order of definition
Definition: proctrans.cpp:181
QString inputDoc(QString v) const
return docu of input element
Definition: proctrans.h:105
bool m_update
Definition: proctrans.h:121
NoLogMode
Log Mode: signals what kind of logging is forbidden.
Definition: proctrans.h:60
static bool isStringType(QString t)
returns true if the type is a string
Definition: proctrans.h:92
QMap< QString, QString > m_outdoc
Definition: proctrans.h:129
bool isDbUpdating() const
returns whether this transaction is considered to update the database
Definition: proctrans.h:118
available even to anonymous/unauthenticated users
Definition: proctrans.h:55
static bool isObjectType(QString t)
return true if the type is an object type
Definition: proctrans.h:100
QStringList inputNames() const
returns the names of all inputs in the order of definition
Definition: proctrans.cpp:159
static QString plainType(QString t)
returns the type without list or xml qualifiers
Definition: proctrans.h:75
default: need a valid session and the privilege
Definition: proctrans.h:51
NoLogMode m_logmode
Definition: proctrans.h:123
static bool isAttributeType(QString t)
returns true if the type is to be encoded as attribute
Definition: proctrans.h:96
NoLogMode logMode() const
Definition: proctrans.h:70
QStringList privileges() const
return privileges that exist inside this transaction
Definition: proctrans.h:115
QString name() const
returns the name of the transaction
Definition: proctrans.h:25
QList< QPair< QString, QString > > m_output
Definition: proctrans.h:125
QStringList docStrings() const
return the documentation of the transaction
Definition: proctrans.h:103
QString outputType(QString) const
returns the type of an output variable
Definition: proctrans.cpp:189
static bool isIntType(QString t)
returns true if the type is integer
Definition: proctrans.h:88
AuthMode m_mode
Definition: proctrans.h:122
QString typeSerializer(QString t) const
returns the XML serializer for Object types
Definition: proctrans.h:82
AuthMode
authentication mode
Definition: proctrans.h:49
bool hasInput(QString v) const
returns whether an input variable exists
Definition: proctrans.cpp:152
static bool isBlobType(QString t)
returns true if the type is a blob
Definition: proctrans.h:94
QMap< QString, QPair< QString, QString > > m_call
Definition: proctrans.h:124
bool isValid() const
returns whether parsing it was successful
Definition: proctrans.h:22
logging the response is forbidden
Definition: proctrans.h:66
logging the request is forbidden
Definition: proctrans.h:64
logging any data is forbidden
Definition: proctrans.h:68
internal representation of a transaction
Definition: proctrans.h:16
QStringList m_privileges
Definition: proctrans.h:126
bool m_valid
Definition: proctrans.h:121
QStringList m_docstrings
Definition: proctrans.h:128
AuthMode authMode() const
Definition: proctrans.h:57
static bool isElementType(QString t)
returns true if the type is to be encoded as element
Definition: proctrans.h:98
bool hasOutput(QString v) const
returns whether an output variable exists
Definition: proctrans.cpp:174
QString m_name
Definition: proctrans.h:120
QString outputDoc(QString v) const
return docu of output element
Definition: proctrans.h:108
default: all logging is allowed
Definition: proctrans.h:62
static bool isListType(QString t)
returns true if the type given is a list
Definition: proctrans.h:73
QString privilegeDoc(QString p) const
return docu of a privilege
Definition: proctrans.h:111
QList< QPair< QString, QString > > m_input
Definition: proctrans.h:125
static bool isBoolType(QString t)
returns true if the type is boolean
Definition: proctrans.h:90
QString callInclude(QString c) const
returns the include file of the called function
Definition: proctrans.h:46
WocTransaction(const QDomElement &)
initializes a transaction from XML
Definition: proctrans.cpp:23
only need to be authenticated, every valid user can do it
Definition: proctrans.h:53
QString inputType(QString) const
returns the type of an input variable
Definition: proctrans.cpp:167
bool hasCall(QString c) const
returns whether a specific language binding exists for a call
Definition: proctrans.h:42