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