Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 188:090cefdab1d1
fix because of Windows macros
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 12 Nov 2012 17:43:12 +0100 |
parents | 8e673a65564d |
children | ccbc2cf64a0d |
comparison
equal
deleted
inserted
replaced
187:8e673a65564d | 188:090cefdab1d1 |
---|---|
137 s.BindString(0, name); | 137 s.BindString(0, name); |
138 s.BindString(1, value); | 138 s.BindString(1, value); |
139 s.Run(); | 139 s.Run(); |
140 } | 140 } |
141 | 141 |
142 bool DatabaseWrapper::FindGlobalProperty(std::string& target, | 142 bool DatabaseWrapper::LookupGlobalProperty(std::string& target, |
143 const std::string& name) | 143 const std::string& name) |
144 { | 144 { |
145 SQLite::Statement s(db_, SQLITE_FROM_HERE, | 145 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
146 "SELECT value FROM GlobalProperties WHERE name=?"); | 146 "SELECT value FROM GlobalProperties WHERE name=?"); |
147 s.BindString(0, name); | 147 s.BindString(0, name); |
148 | 148 |
159 | 159 |
160 std::string DatabaseWrapper::GetGlobalProperty(const std::string& name, | 160 std::string DatabaseWrapper::GetGlobalProperty(const std::string& name, |
161 const std::string& defaultValue) | 161 const std::string& defaultValue) |
162 { | 162 { |
163 std::string s; | 163 std::string s; |
164 if (FindGlobalProperty(s, name)) | 164 if (LookupGlobalProperty(s, name)) |
165 { | 165 { |
166 return s; | 166 return s; |
167 } | 167 } |
168 else | 168 else |
169 { | 169 { |
179 s.BindString(1, publicId); | 179 s.BindString(1, publicId); |
180 s.Run(); | 180 s.Run(); |
181 return db_.GetLastInsertRowId(); | 181 return db_.GetLastInsertRowId(); |
182 } | 182 } |
183 | 183 |
184 bool DatabaseWrapper::FindResource(const std::string& publicId, | 184 bool DatabaseWrapper::LookupResource(const std::string& publicId, |
185 int64_t& id, | 185 int64_t& id, |
186 ResourceType& type) | 186 ResourceType& type) |
187 { | 187 { |
188 SQLite::Statement s(db_, SQLITE_FROM_HERE, | 188 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
189 "SELECT internalId, resourceType FROM Resources WHERE publicId=?"); | 189 "SELECT internalId, resourceType FROM Resources WHERE publicId=?"); |
190 s.BindString(0, publicId); | 190 s.BindString(0, publicId); |
191 | 191 |
238 s.BindInt(1, type); | 238 s.BindInt(1, type); |
239 s.BindString(2, value); | 239 s.BindString(2, value); |
240 s.Run(); | 240 s.Run(); |
241 } | 241 } |
242 | 242 |
243 bool DatabaseWrapper::FindMetadata(std::string& target, | 243 bool DatabaseWrapper::LookupMetadata(std::string& target, |
244 int64_t id, | 244 int64_t id, |
245 MetadataType type) | 245 MetadataType type) |
246 { | 246 { |
247 SQLite::Statement s(db_, SQLITE_FROM_HERE, | 247 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
248 "SELECT value FROM Metadata WHERE id=? AND type=?"); | 248 "SELECT value FROM Metadata WHERE id=? AND type=?"); |
249 s.BindInt(0, id); | 249 s.BindInt(0, id); |
250 s.BindInt(1, type); | 250 s.BindInt(1, type); |
263 std::string DatabaseWrapper::GetMetadata(int64_t id, | 263 std::string DatabaseWrapper::GetMetadata(int64_t id, |
264 MetadataType type, | 264 MetadataType type, |
265 const std::string& defaultValue) | 265 const std::string& defaultValue) |
266 { | 266 { |
267 std::string s; | 267 std::string s; |
268 if (FindMetadata(s, id, type)) | 268 if (LookupMetadata(s, id, type)) |
269 { | 269 { |
270 return s; | 270 return s; |
271 } | 271 } |
272 else | 272 else |
273 { | 273 { |
290 s.BindInt(4, uncompressedSize); | 290 s.BindInt(4, uncompressedSize); |
291 s.BindInt(5, compressionType); | 291 s.BindInt(5, compressionType); |
292 s.Run(); | 292 s.Run(); |
293 } | 293 } |
294 | 294 |
295 bool DatabaseWrapper::FindFile(int64_t id, | 295 bool DatabaseWrapper::LookupFile(int64_t id, |
296 const std::string& name, | 296 const std::string& name, |
297 std::string& fileUuid, | 297 std::string& fileUuid, |
298 uint64_t& compressedSize, | 298 uint64_t& compressedSize, |
299 uint64_t& uncompressedSize, | 299 uint64_t& uncompressedSize, |
300 CompressionType& compressionType) | 300 CompressionType& compressionType) |
301 { | 301 { |
302 SQLite::Statement s(db_, SQLITE_FROM_HERE, | 302 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
303 "SELECT uuid, compressedSize, uncompressedSize, compressionType FROM AttachedFiles WHERE id=? AND name=?"); | 303 "SELECT uuid, compressedSize, uncompressedSize, compressionType FROM AttachedFiles WHERE id=? AND name=?"); |
304 s.BindInt(0, id); | 304 s.BindInt(0, id); |
305 s.BindString(1, name); | 305 s.BindString(1, name); |