| 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: 31 янв. 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_INTEGER_H_ |
| 23 |
#define LSP_PLUG_IN_FMT_JSON_DOM_INTEGER_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 integer type |
| 34 |
*/ |
| 35 |
class Integer: public Node |
| 36 |
{ |
| 37 |
public: |
| 38 |
inline Integer(): Node() {} |
| 39 |
inline Integer(const Node &src): Node(src) {} |
| 40 |
inline Integer(const Node *src): Node(src) {} |
| 41 |
|
| 42 |
public: |
| 43 |
Integer &operator = (const Node &src) { copy_ref(&src); return *this; } |
| 44 |
Integer &operator = (const Node *src) { copy_ref(src); return *this; } |
| 45 |
|
| 46 |
Integer &assign(const Node &src) { copy_ref(&src); return *this; } |
| 47 |
Integer &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(ssize_t value); |
| 55 |
|
| 56 |
static Integer *allocate(ssize_t value = 0); |
| 57 |
|
| 58 |
static Integer build(ssize_t value = 0); |
| 59 |
|
| 60 |
public: |
| 61 |
/** |
| 62 |
* Try to cast value to integer and return the casted value |
| 63 |
* @return integer value or 0 if cast was unsuccessful |
| 64 |
*/ |
| 65 |
ssize_t get() const; |
| 66 |
|
| 67 |
/** |
| 68 |
* Strict get: check that value is of integer type and return it |
| 69 |
* @return integer value or 0 if value is not integer |
| 70 |
*/ |
| 71 |
ssize_t sget() const; |
| 72 |
|
| 73 |
/** |
| 74 |
* Cast value to integer |
| 75 |
* @return success if value has been successful casted |
| 76 |
*/ |
| 77 |
status_t cast(); |
| 78 |
|
| 79 |
/** |
| 80 |
* Cast to integer and set value |
| 81 |
* @param value value to set |
| 82 |
* @return success if property has been set |
| 83 |
*/ |
| 84 |
status_t set(ssize_t value); |
| 85 |
|
| 86 |
/** |
| 87 |
* Strict set: check that value is of integer type and change it |
| 88 |
* @param value value to set |
| 89 |
* @return success if value has been set |
| 90 |
*/ |
| 91 |
status_t sset(ssize_t value); |
| 92 |
}; |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
#endif /* LSP_PLUG_IN_FMT_JSON_DOM_INTEGER_H_ */ |