Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/fmt/json/dom/String.h

raw
1 /*
2 * Copyright (C) 2021 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2021 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 23 февр. 2021 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_FMT_JSON_DOM_STRING_H_
23 #define LSP_PLUG_IN_FMT_JSON_DOM_STRING_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/fmt/json/dom/Node.h>
27
28 namespace lsp
29 {
30 namespace json
31 {
32 /**
33 * JSON node of String type
34 */
35 class String: public Node
36 {
37 public:
38 inline String(): Node() {}
39 inline String(const Node &src): Node(src) {}
40 inline String(const Node *src): Node(src) {}
41
42 public:
43 String &operator = (const Node &src) { copy_ref(&src); return *this; }
44 String &operator = (const Node *src) { copy_ref(src); return *this; }
45
46 String &assign(const Node &src) { copy_ref(&src); return *this; }
47 String &assign(const Node *src) { copy_ref(src); return *this; }
48
49 public:
50 virtual bool valid() const;
51
52 virtual status_t create();
53
54 status_t create(const LSPString *value);
55 status_t create(const char *value, const char *charset = NULL);
56
57 static String *allocate();
58 static String *allocate(const LSPString *value);
59 static String *allocate(const char *value, const char *charset = NULL);
60
61 static String build();
62 static String build(const LSPString *value);
63 static String build(const char *value, const char *charset = NULL);
64
65 public:
66 /**
67 * Try to cast value to String and return the casted value
68 * @return String value or NULL if cast was unsuccessful
69 */
70 status_t get(LSPString *dst) const;
71
72 /**
73 * Strict get: check that value is of String type and return it
74 * @return String value or 0 if value is not String
75 */
76 status_t sget(LSPString *dst) const;
77
78 /**
79 * Cast value to String
80 * @return success if value has been successful casted
81 */
82 status_t cast();
83
84 /**
85 * Cast to String and set value
86 * @param value value to set
87 * @return success if property has been set
88 */
89 status_t set(const LSPString *value);
90
91 /**
92 * Cast to String and set value
93 * @param value value to set
94 * @return success if property has been set
95 */
96 status_t set(const char *value, const char *charset = NULL);
97
98 /**
99 * Strict set: check that value is of String type and change it
100 * @param value value to set
101 * @return success if value has been set
102 */
103 status_t sset(const LSPString *value);
104
105 /**
106 * Strict set: check that value is of String type and change it
107 * @param value value to set
108 * @return success if value has been set
109 */
110 status_t sset(const char *value, const char *charset = NULL);
111 };
112 }
113 }
114
115
116
117
118
119 #endif /* LSP_PLUG_IN_FMT_JSON_DOM_STRING_H_ */