~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
1 by brian
clean slate
20
21
/*  Extra functions used by unireg library */
22
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
23
#pragma once
670.2.4 by Monty Taylor
Removed more stuff from the headers.
24
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
25
#include <drizzled/visibility.h>
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
26
#include <sstream>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
27
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
28
namespace drizzled
29
{
30
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
31
void unireg_exit() __attribute__((noreturn));
32
DRIZZLED_API void unireg_actual_abort(const char *file, int line, const char *func, const std::string& message) __attribute__((noreturn));
2363.1.8 by Brian Aker
--help and --version now work a bit more quickly. Also, we don't have to worry about root messing up file creation.
33
void unireg_startup_finished();
2363.1.6 by Brian Aker
Add better error messages for issues on startup.
34
35
namespace stream {
36
37
namespace detail {
38
39
template<class Ch, class Tr, class A>
40
  class _unireg {
41
  private:
42
43
  public:
44
    typedef std::basic_ostringstream<Ch, Tr, A> stream_buffer;
45
46
  public:
47
    void operator()(const stream_buffer &s, const char *filename, int line, const char *func)
48
    {
49
      unireg_actual_abort(filename, line, func, s.str());
50
    }
51
  };
52
53
template<template <class Ch, class Tr, class A> class OutputPolicy, class Ch = char, class Tr = std::char_traits<Ch>, class A = std::allocator<Ch> >
54
  class log {
55
  private:
56
    typedef OutputPolicy<Ch, Tr, A> output_policy;
57
    const char *_filename;
58
    int _line_number;
59
    const char *_func;
60
61
  public:
62
    log() :
63
      _filename(NULL),
64
      _line_number(0),
65
      _func(NULL)
66
    { }
67
68
    void set_filename(const char *filename, int line_number, const char *func)
69
    {
70
      _filename= filename;
71
      _line_number= line_number;
72
      _func= func;
73
    }
74
75
    ~log()
76
    {
77
      output_policy()(arg, _filename, _line_number, _func);
78
    }
79
80
  public:
81
    template<class T>
82
      log &operator<<(const T &x)
83
      {
84
        arg << x;
85
        return *this;
86
      }
87
88
  private:
89
    typename output_policy::stream_buffer arg;
90
  };
91
} // namespace detail
92
93
class _unireg : public detail::log<detail::_unireg> {
94
public:
95
  _unireg(const char *filename, int line_number, const char *func)
96
  {
97
    set_filename(filename, line_number, func);
98
  }
99
};
100
101
} // namespace stream
102
103
#define unireg_abort stream::_unireg(__FILE__, __LINE__, __func__)
670.2.4 by Monty Taylor
Removed more stuff from the headers.
104
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
105
} /* namespace drizzled */