Mercurial > hg > orthanc
comparison Core/SQLite/StatementReference.cpp @ 50:a15e90e5d6fc
rename in code
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Sep 2012 15:50:12 +0200 |
parents | db4d996ea264 |
children | c996319e90bc |
comparison
equal
deleted
inserted
replaced
49:e1a3ae0dadf3 | 50:a15e90e5d6fc |
---|---|
1 /** | 1 /** |
2 * Palantir - A Lightweight, RESTful DICOM Store | 2 * Palanthir - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, | 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, |
4 * Belgium | 4 * Belgium |
5 * | 5 * |
6 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 6 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
7 * | 7 * |
34 **/ | 34 **/ |
35 | 35 |
36 | 36 |
37 #include "StatementReference.h" | 37 #include "StatementReference.h" |
38 | 38 |
39 #include "../PalantirException.h" | 39 #include "../PalanthirException.h" |
40 | 40 |
41 #include <cassert> | 41 #include <cassert> |
42 #include "sqlite3.h" | 42 #include "sqlite3.h" |
43 | 43 |
44 namespace Palantir | 44 namespace Palanthir |
45 { | 45 { |
46 namespace SQLite | 46 namespace SQLite |
47 { | 47 { |
48 bool StatementReference::IsRoot() const | 48 bool StatementReference::IsRoot() const |
49 { | 49 { |
61 StatementReference::StatementReference(sqlite3* database, | 61 StatementReference::StatementReference(sqlite3* database, |
62 const char* sql) | 62 const char* sql) |
63 { | 63 { |
64 if (database == NULL || sql == NULL) | 64 if (database == NULL || sql == NULL) |
65 { | 65 { |
66 throw PalantirException(ErrorCode_ParameterOutOfRange); | 66 throw PalanthirException(ErrorCode_ParameterOutOfRange); |
67 } | 67 } |
68 | 68 |
69 root_ = NULL; | 69 root_ = NULL; |
70 refCount_ = 0; | 70 refCount_ = 0; |
71 | 71 |
72 int error = sqlite3_prepare_v2(database, sql, -1, &statement_, NULL); | 72 int error = sqlite3_prepare_v2(database, sql, -1, &statement_, NULL); |
73 if (error != SQLITE_OK) | 73 if (error != SQLITE_OK) |
74 { | 74 { |
75 throw PalantirException("SQLite: " + std::string(sqlite3_errmsg(database))); | 75 throw PalanthirException("SQLite: " + std::string(sqlite3_errmsg(database))); |
76 } | 76 } |
77 | 77 |
78 assert(IsRoot()); | 78 assert(IsRoot()); |
79 } | 79 } |
80 | 80 |
102 if (IsRoot()) | 102 if (IsRoot()) |
103 { | 103 { |
104 if (refCount_ != 0) | 104 if (refCount_ != 0) |
105 { | 105 { |
106 // There remain references to this object | 106 // There remain references to this object |
107 throw PalantirException(ErrorCode_InternalError); | 107 throw PalanthirException(ErrorCode_InternalError); |
108 } | 108 } |
109 else if (statement_ != NULL) | 109 else if (statement_ != NULL) |
110 { | 110 { |
111 sqlite3_finalize(statement_); | 111 sqlite3_finalize(statement_); |
112 } | 112 } |
113 } | 113 } |
114 else | 114 else |
115 { | 115 { |
116 if (root_->refCount_ == 0) | 116 if (root_->refCount_ == 0) |
117 { | 117 { |
118 throw PalantirException(ErrorCode_InternalError); | 118 throw PalanthirException(ErrorCode_InternalError); |
119 } | 119 } |
120 else | 120 else |
121 { | 121 { |
122 root_->refCount_--; | 122 root_->refCount_--; |
123 } | 123 } |