monotone

monotone Mtn Source Tree

Root/base.hh

1// Copyright (C) 2007 Zack Weinberg <zackw@panix.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#ifndef __BASE_HH__
11#define __BASE_HH__
12
13// This file contains a small number of inclusions and declarations that
14// should be visible to the entire program. Include it first.
15
16// Configuration directives
17#include "config.h"
18
19#define BOOST_DISABLE_THREADS
20#define BOOST_SP_DISABLE_THREADS
21#define BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
22
23// Undefine this if you do not want to support SQLite versions older
24// than 3.3.14.
25#define SUPPORT_SQLITE_BEFORE_3003014
26
27#include <iosfwd>
28#include <string> // it would be nice if there were a <stringfwd>
29
30// s32, u64, etc
31#include "numeric_vocab.hh"
32
33// this template must be specialized for each type you want to dump
34// (or apply MM() to -- see sanity.hh). there are a few stock dumpers
35// in appropriate places.
36template <typename T>
37void dump(T const &, std::string &)
38{
39 // the compiler will evaluate this somewhat odd construct (and issue an
40 // error) if and only if this base template is instantiated. we do not
41 // use BOOST_STATIC_ASSERT mainly to avoid dragging it in everywhere;
42 // also we get better diagnostics this way (the error tells you what is
43 // wrong, not just that there's an assertion failure).
44 enum dummy { d = (sizeof(struct dump_must_be_specialized_for_this_type)
45 == sizeof(T)) };
46}
47
48template <> void dump(std::string const & obj, std::string & out);
49template <> void dump(char const * const & obj, std::string & out);
50template <> void dump(bool const & obj, std::string & out);
51template <> void dump(int const & obj, std::string & out);
52template <> void dump(unsigned int const & obj, std::string & out);
53template <> void dump(long const & obj, std::string & out);
54template <> void dump(unsigned long const & obj, std::string & out);
55#ifdef USING_LONG_LONG
56// I don't think these are standard, so only specialize on them
57// if we're actually using them.
58template <> void dump(long long const & obj, std::string & out);
59template <> void dump(unsigned long long const & obj, std::string & out);
60#endif
61
62// NORETURN(void function()); declares a function that will never return
63// in the normal fashion. a function that invariably throws an exception
64// counts as NORETURN.
65#if defined(__GNUC__)
66#define NORETURN(x) x __attribute__((noreturn))
67#elif defined(_MSC_VER)
68#define NORETURN(x) __declspec(noreturn) x
69#else
70#define NORETURN(x) x
71#endif
72
73// SQLite versions before 3.3.14 did not have sqlite_prepare_v2. To support
74// those SQLite libraries, we must use the old API.
75#ifdef SUPPORT_SQLITE_BEFORE_3003014
76#define sqlite3_prepare_v2 sqlite3_prepare
77#endif
78
79// i18n goo
80
81#include "gettext.h"
82
83#define _(str) gettext(str)
84#define N_(str) gettext_noop(str)
85
86#endif // __BASE_HH__
87
88// Local Variables:
89// mode: C++
90// fill-column: 76
91// c-file-style: "gnu"
92// indent-tabs-mode: nil
93// End:
94// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status