reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
SqlDb.hxx
Go to the documentation of this file.
1#if !defined(RESIP_SQLDB_HXX)
2#define RESIP_SQLDB_HXX
3
5#include "rutil/Data.hxx"
7
8namespace resip
9{
10 class TransactionUser;
11}
12
13namespace repro
14{
15
16class SqlDb: public AbstractDb
17{
18 public:
20
21 virtual bool isSane() {return mConnected;}
22
23 virtual void eraseUser( const Key& key );
24 virtual void eraseTlsPeerIdentity( const Key& key );
25
26 virtual bool isAuthorized(const std::set<resip::Data>& peerNames, const std::set<resip::Data>& identities) const;
27
28 // Perform a query that expects a single result/row - returns all column/field data in a vector
29 virtual int singleResultQuery(const resip::Data& queryCommand, std::vector<resip::Data>& fields) const = 0;
30
31 protected:
32 virtual void setConnected(bool connected) const { mConnected = connected; }
33 virtual bool isConnected() const { return mConnected; }
34
35 void setToData(const std::set<resip::Data>& items, resip::Data& result, const resip::Data& sep = ",", const char quote = '\'') const;
36
37 // when multiple threads are in use with the same connection, you need to
38 // mutex calls to mysql_query and mysql_store_result:
39 // http://dev.mysql.com/doc/refman/5.1/en/threaded-clients.html
41
43
44 private:
45 // Db manipulation routines
46 virtual void dbEraseRecord(const Table table,
47 const resip::Data& key,
48 bool isSecondaryKey=false); // allows deleting records from a table that supports secondary keying using a secondary key
49 virtual bool dbBeginTransaction(const Table table) = 0;
50 virtual bool dbCommitTransaction(const Table table);
51 virtual bool dbRollbackTransaction(const Table table);
52
53 virtual int query(const resip::Data& queryCommand) const = 0;
54 virtual resip::Data& escapeString(const resip::Data& str, resip::Data& escapedStr) const = 0;
55
56 mutable volatile bool mConnected;
57 resip::Data mTlsPeerAuthorizationQuery;
58 resip::Data mTableNamePrefix;
59
60 virtual void userWhereClauseToDataStream(const Key& key, resip::DataStream& ds) const = 0;
61 virtual void tlsPeerIdentityWhereClauseToDataStream(const Key& key, resip::DataStream& ds) const = 0;
62};
63
64}
65#endif
66
67/* ====================================================================
68 *
69 * Copyright (c) 2015 Daniel Pocock. All rights reserved.
70 *
71 * Redistribution and use in source and binary forms, with or without
72 * modification, are permitted provided that the following conditions
73 * are met:
74 *
75 * 1. Redistributions of source code must retain the above copyright
76 * notice, this list of conditions and the following disclaimer.
77 *
78 * 2. Redistributions in binary form must reproduce the above copyright
79 * notice, this list of conditions and the following disclaimer in
80 * the documentation and/or other materials provided with the
81 * distribution.
82 *
83 * 3. Neither the name of the author(s) nor the names of any contributors
84 * may be used to endorse or promote products derived from this software
85 * without specific prior written permission.
86 *
87 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
88 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
89 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
90 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
91 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
92 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
93 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
94 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
95 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
96 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
97 * SUCH DAMAGE.
98 *
99 * ====================================================================
100 */
101
static const Data sep("[]")
virtual bool isConnected() const
Definition SqlDb.hxx:33
virtual bool isAuthorized(const std::set< resip::Data > &peerNames, const std::set< resip::Data > &identities) const
Definition SqlDb.cxx:78
virtual void eraseUser(const Key &key)
Definition SqlDb.cxx:31
resip::Data tableName(Table table) const
Definition SqlDb.cxx:161
virtual void eraseTlsPeerIdentity(const Key &key)
Definition SqlDb.cxx:43
virtual void setConnected(bool connected) const
Definition SqlDb.hxx:32
virtual int singleResultQuery(const resip::Data &queryCommand, std::vector< resip::Data > &fields) const =0
void setToData(const std::set< resip::Data > &items, resip::Data &result, const resip::Data &sep=",", const char quote='\'') const
Definition SqlDb.cxx:55
resip::Mutex mMutex
Definition SqlDb.hxx:40
virtual bool isSane()
Definition SqlDb.hxx:21
An iostream that operates on an existing Data.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37
void list()
Definition userAdmin.cxx:66