aboutsummaryrefslogtreecommitdiff
path: root/ql/types/string.py
diff options
context:
space:
mode:
authorBicker <bickerkards@tuta.io>2019-05-22 17:45:37 +0200
committerBicker <bickerkards@tuta.io>2019-05-22 17:45:37 +0200
commit25314fd2aed81aa5281bc3d93dbcc7919368ebe1 (patch)
tree1995521ee652e419926de5fced0f2e3b655e70fb /ql/types/string.py
Initial commitHEADmaster
Diffstat (limited to 'ql/types/string.py')
-rw-r--r--ql/types/string.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/ql/types/string.py b/ql/types/string.py
new file mode 100644
index 0000000..ece46a7
--- /dev/null
+++ b/ql/types/string.py
@@ -0,0 +1,55 @@
+from gui.widgets.line_edit import LineEdit
+from ql.ast.nodes.expressions.literals.string_literal import StringNode
+from ql.types.boolean import QLBoolean
+from ql.types.type import QLType
+
+
+class QLString(QLType):
+ def __init__(self, value=''):
+ super(QLString, self).__init__()
+ self.__value = str(value)
+
+ @property
+ def value(self):
+ return self.__value
+
+ def __repr__(self):
+ return str(self.value)
+
+ def __str__(self):
+ return str(self.value)
+
+ def __eq__(self, other):
+ if isinstance(other, QLString):
+ return QLBoolean(self.value == other.value)
+
+ return QLBoolean(False)
+
+ def __ne__(self, other):
+ return QLBoolean(not self == other)
+
+ def __lt__(self, other):
+ return QLBoolean(len(self.value) < len(other.value))
+
+ def __gt__(self, other):
+ return QLBoolean(len(self.value) > len(other.value))
+
+ def __le__(self, other):
+ return QLBoolean(len(self.value) <= len(other.value))
+
+ def __ge__(self, other):
+ return QLBoolean(len(self.value) >= len(other.value))
+
+ def __add__(self, other):
+ return QLString(self.value + other.value)
+
+ def get_json_value(self):
+ return self.value
+
+ @staticmethod
+ def get_literal_node(value):
+ return StringNode(None, QLString, value)
+
+ @staticmethod
+ def pyqt5_default_widget():
+ return LineEdit()