| 1 | /* |
| 2 | * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | #include <pjsua2/persistent.hpp> |
| 19 | |
| 20 | using namespace pj; |
| 21 | using namespace std; |
| 22 | |
| 23 | |
| 24 | bool PersistentDocument::hasUnread() const |
| 25 | { |
| 26 | return getRootContainer().hasUnread(); |
| 27 | } |
| 28 | |
| 29 | string PersistentDocument::unreadName() const PJSUA2_THROW(Error) |
| 30 | { |
| 31 | return getRootContainer().unreadName(); |
| 32 | } |
| 33 | |
| 34 | int PersistentDocument::readInt(const string &name) const PJSUA2_THROW(Error) |
| 35 | { |
| 36 | return (int)getRootContainer().readNumber(name); |
| 37 | } |
| 38 | |
| 39 | float PersistentDocument::readNumber(const string &name) const |
| 40 | PJSUA2_THROW(Error) |
| 41 | { |
| 42 | return getRootContainer().readNumber(name); |
| 43 | } |
| 44 | |
| 45 | bool PersistentDocument::readBool(const string &name) const |
| 46 | PJSUA2_THROW(Error) |
| 47 | { |
| 48 | return getRootContainer().readBool(name); |
| 49 | } |
| 50 | |
| 51 | string PersistentDocument::readString(const string &name) const |
| 52 | PJSUA2_THROW(Error) |
| 53 | { |
| 54 | return getRootContainer().readString(name); |
| 55 | } |
| 56 | |
| 57 | StringVector PersistentDocument::readStringVector(const string &name) const |
| 58 | PJSUA2_THROW(Error) |
| 59 | { |
| 60 | return getRootContainer().readStringVector(name); |
| 61 | } |
| 62 | |
| 63 | void PersistentDocument::readObject(PersistentObject &obj) const |
| 64 | PJSUA2_THROW(Error) |
| 65 | { |
| 66 | getRootContainer().readObject(obj); |
| 67 | } |
| 68 | |
| 69 | ContainerNode PersistentDocument::readContainer(const string &name) const |
| 70 | PJSUA2_THROW(Error) |
| 71 | { |
| 72 | return getRootContainer().readContainer(name); |
| 73 | } |
| 74 | |
| 75 | ContainerNode PersistentDocument::readArray(const string &name) const |
| 76 | PJSUA2_THROW(Error) |
| 77 | { |
| 78 | return getRootContainer().readArray(name); |
| 79 | } |
| 80 | |
| 81 | void PersistentDocument::writeNumber(const string &name, |
| 82 | float num) PJSUA2_THROW(Error) |
| 83 | { |
| 84 | getRootContainer().writeNumber(name, num); |
| 85 | } |
| 86 | |
| 87 | void PersistentDocument::writeInt(const string &name, |
| 88 | int num) PJSUA2_THROW(Error) |
| 89 | { |
| 90 | getRootContainer().writeNumber(name, (float)num); |
| 91 | } |
| 92 | |
| 93 | void PersistentDocument::writeBool(const string &name, |
| 94 | bool value) PJSUA2_THROW(Error) |
| 95 | { |
| 96 | getRootContainer().writeBool(name, value); |
| 97 | } |
| 98 | |
| 99 | void PersistentDocument::writeString(const string &name, |
| 100 | const string &value) PJSUA2_THROW(Error) |
| 101 | { |
| 102 | getRootContainer().writeString(name, value); |
| 103 | } |
| 104 | |
| 105 | void PersistentDocument::writeStringVector(const string &name, |
| 106 | const StringVector &value) |
| 107 | PJSUA2_THROW(Error) |
| 108 | { |
| 109 | getRootContainer().writeStringVector(name, value); |
| 110 | } |
| 111 | |
| 112 | void PersistentDocument::writeObject(const PersistentObject &obj) |
| 113 | PJSUA2_THROW(Error) |
| 114 | { |
| 115 | getRootContainer().writeObject(obj); |
| 116 | } |
| 117 | |
| 118 | ContainerNode PersistentDocument::writeNewContainer(const string &name) |
| 119 | PJSUA2_THROW(Error) |
| 120 | { |
| 121 | return getRootContainer().writeNewContainer(name); |
| 122 | } |
| 123 | |
| 124 | ContainerNode PersistentDocument::writeNewArray(const string &name) |
| 125 | PJSUA2_THROW(Error) |
| 126 | { |
| 127 | return getRootContainer().writeNewArray(name); |
| 128 | } |
| 129 | |
| 130 | /////////////////////////////////////////////////////////////////////////////// |
| 131 | |
| 132 | bool ContainerNode::hasUnread() const |
| 133 | { |
| 134 | return op->hasUnread(this); |
| 135 | } |
| 136 | |
| 137 | string ContainerNode::unreadName() const PJSUA2_THROW(Error) |
| 138 | { |
| 139 | return op->unreadName(this); |
| 140 | } |
| 141 | |
| 142 | int ContainerNode::readInt(const string &name) const PJSUA2_THROW(Error) |
| 143 | { |
| 144 | return (int)op->readNumber(this, name); |
| 145 | } |
| 146 | |
| 147 | float ContainerNode::readNumber(const string &name) const PJSUA2_THROW(Error) |
| 148 | { |
| 149 | return op->readNumber(this, name); |
| 150 | } |
| 151 | |
| 152 | bool ContainerNode::readBool(const string &name) const PJSUA2_THROW(Error) |
| 153 | { |
| 154 | return op->readBool(this, name); |
| 155 | } |
| 156 | |
| 157 | string ContainerNode::readString(const string &name) const PJSUA2_THROW(Error) |
| 158 | { |
| 159 | return op->readString(this, name); |
| 160 | } |
| 161 | |
| 162 | StringVector ContainerNode::readStringVector(const string &name) const |
| 163 | PJSUA2_THROW(Error) |
| 164 | { |
| 165 | return op->readStringVector(this, name); |
| 166 | } |
| 167 | |
| 168 | void ContainerNode::readObject(PersistentObject &obj) const |
| 169 | PJSUA2_THROW(Error) |
| 170 | { |
| 171 | obj.readObject(*this); |
| 172 | } |
| 173 | |
| 174 | ContainerNode ContainerNode::readContainer(const string &name) const |
| 175 | PJSUA2_THROW(Error) |
| 176 | { |
| 177 | return op->readContainer(this, name); |
| 178 | } |
| 179 | |
| 180 | ContainerNode ContainerNode::readArray(const string &name) const |
| 181 | PJSUA2_THROW(Error) |
| 182 | { |
| 183 | return op->readArray(this, name); |
| 184 | } |
| 185 | |
| 186 | void ContainerNode::writeNumber(const string &name, |
| 187 | float num) PJSUA2_THROW(Error) |
| 188 | { |
| 189 | return op->writeNumber(this, name, num); |
| 190 | } |
| 191 | |
| 192 | void ContainerNode::writeInt(const string &name, |
| 193 | int num) PJSUA2_THROW(Error) |
| 194 | { |
| 195 | return op->writeNumber(this, name, (float)num); |
| 196 | } |
| 197 | |
| 198 | void ContainerNode::writeBool(const string &name, |
| 199 | bool value) PJSUA2_THROW(Error) |
| 200 | { |
| 201 | return op->writeBool(this, name, value); |
| 202 | } |
| 203 | |
| 204 | void ContainerNode::writeString(const string &name, |
| 205 | const string &value) PJSUA2_THROW(Error) |
| 206 | { |
| 207 | return op->writeString(this, name, value); |
| 208 | } |
| 209 | |
| 210 | void ContainerNode::writeStringVector(const string &name, |
| 211 | const StringVector &value) |
| 212 | PJSUA2_THROW(Error) |
| 213 | { |
| 214 | return op->writeStringVector(this, name, value); |
| 215 | } |
| 216 | |
| 217 | void ContainerNode::writeObject(const PersistentObject &obj) |
| 218 | PJSUA2_THROW(Error) |
| 219 | { |
| 220 | obj.writeObject(*this); |
| 221 | } |
| 222 | |
| 223 | ContainerNode ContainerNode::writeNewContainer(const string &name) |
| 224 | PJSUA2_THROW(Error) |
| 225 | { |
| 226 | return op->writeNewContainer(this, name); |
| 227 | } |
| 228 | |
| 229 | ContainerNode ContainerNode::writeNewArray(const string &name) |
| 230 | PJSUA2_THROW(Error) |
| 231 | { |
| 232 | return op->writeNewArray(this, name); |
| 233 | } |