aboutsummaryrefslogtreecommitdiff
path: root/ql/types/string.py
blob: ece46a7da91ea090db4dfaaa15d95a278b5714fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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()