preparations for woc integration
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 8 Feb 2009 15:31:41 +0000 (15:31 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 8 Feb 2009 15:31:41 +0000 (15:31 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@266 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/smoke.pro
src/wbase/nullable.h [new file with mode: 0644]
src/wbase/wbase.pri [new file with mode: 0644]

index 27f8108..83deff3 100644 (file)
@@ -96,4 +96,6 @@ TRANSLATIONS = \
 
 
 include(../zip/zip.pri)
+include(wbase/wbase.pri)
+
 LIBS += -lgmp
diff --git a/src/wbase/nullable.h b/src/wbase/nullable.h
new file mode 100644 (file)
index 0000000..7a802eb
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// C++ Interface: nullable
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+
+#ifndef WOLF_NULLABLE_H
+#define WOLF_NULLABLE_H
+
+template<class T>class Nullable
+{
+       public:
+               Nullable(){isnull=true;}
+               Nullable(const T&t){isnull=false;elem=t;}
+               Nullable(const Nullable<T>&t){isnull=t.isnull;elem=t.elem;}
+               
+               Nullable<T>& operator=(const T&t){isnull=false;elem=t;}
+               Nullable<T>& operator=(const Nullable<T>&t){isnull=t.isnull;elem=t.elem;}
+               
+               bool isNull()const{return isnull;}
+               
+               operator T()const{if(isnull)return T();else return elem;}
+               
+               T& value(){return elem;}
+               T value()const{if(isnull)return T();else return elem;}
+       private:
+               bool isnull;
+               T elem;
+};
+
+typedef Nullable<int> Int;
+typedef Nullable<qint32> Int32;
+typedef Nullable<qint64> Int64;
+typedef Nullable<quint32> UInt32;
+typedef Nullable<quint64> UInt64;
+typedef Nullable<QString> NString;
+
+#endif
diff --git a/src/wbase/wbase.pri b/src/wbase/wbase.pri
new file mode 100644 (file)
index 0000000..cb96ee1
--- /dev/null
@@ -0,0 +1 @@
+HEADERS += wbase/nullable.h