blob: d09439771788a9cb830c0fcd7aa7e7f88b9defc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// file : odb/database.cxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <string>
#include <istream>
#include <ostream>
#include <algorithm> // std::lower_bound
#include <odb/database.hxx>
using namespace std;
static const char* str[] =
{
"mysql",
"tracer"
};
const char* database::
string () const
{
return str[v_];
}
istream&
operator>> (istream& is, database& db)
{
string s;
is >> s;
if (!is.fail ())
{
const char** e (str + sizeof (str) / sizeof (char*));
const char** i (lower_bound (str, e, s));
if (i != e && *i == s)
db = database::value (i - str);
else
is.setstate (istream::failbit);
}
return is;
}
ostream&
operator<< (ostream& os, database db)
{
return os << db.string ();
}
|