monotone

monotone Mtn Source Tree

Root/vocab.hh

1#ifndef __VOCAB_HH__
2#define __VOCAB_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include "config.h"
14
15#include <utility>
16#include <string>
17#include <iosfwd>
18
19// the purpose of this file is to wrap things which are otherwise strings
20// in a bit of typesafety, set up enumerations and tuple-types, and
21// generally describe the "vocabulary" (nouns anyways) that modules in this
22// program use.
23
24template <typename T>
25void dump(T const &, std::string &);
26
27#include "vocab_macros.hh"
28#define ENCODING(enc) hh_ENCODING(enc)
29#define DECORATE(dec) hh_DECORATE(dec)
30#define ATOMIC(ty) hh_ATOMIC(ty)
31#define ATOMIC_NOVERIFY(ty) hh_ATOMIC_NOVERIFY(ty)
32
33inline bool is_xdigit(char x)
34{
35 return ((x >= '0' && x <= '9')
36 || (x >= 'a' && x <= 'f')
37 || (x >= 'A' && x <= 'F'));
38}
39
40inline bool is_alpha(char x)
41{
42 return ((x >= 'a' && x <= 'z')
43 || (x >= 'A' && x <= 'Z'));
44}
45
46inline bool is_alnum(char x)
47{
48 return ((x >= '0' && x <= '9')
49 || (x >= 'a' && x <= 'z')
50 || (x >= 'A' && x <= 'Z'));
51}
52
53inline bool is_space(char x)
54{
55 return (x == ' ')
56 || (x == '\n')
57 || (x == '\t')
58 || (x == '\r')
59 || (x == '\v')
60 || (x == '\f');
61}
62
63
64#ifdef HAVE_EXTERN_TEMPLATE
65#define EXTERN extern
66#else
67#define EXTERN /* */
68#endif
69
70#include "vocab_terms.hh"
71
72#undef ATOMIC
73#undef ATOMIC_NOVERIFY
74#undef DECORATE
75#undef ENCODING
76
77// most of the time you want to use these typedefs and forget
78// about the stuff in vocab_terms.hh
79
80typedef revision< hexenc<id> > revision_id;
81typedef roster< hexenc<id> > roster_id;
82typedef manifest< hexenc<id> > manifest_id;
83typedef file< hexenc<id> > file_id;
84typedef key< hexenc<id> > key_id;
85typedef epoch< hexenc<id> > epoch_id;
86typedef epoch< hexenc<data> > epoch_data;
87
88typedef revision< data > revision_data;
89typedef roster< data > roster_data;
90typedef manifest< data > manifest_data;
91typedef file< data > file_data;
92
93typedef manifest< delta > manifest_delta;
94typedef file< delta > file_delta;
95
96typedef std::pair<var_domain, var_name> var_key;
97
98
99struct keypair
100{
101 base64<rsa_pub_key> pub;
102 base64<rsa_priv_key> priv;
103 keypair()
104 {}
105 keypair(base64<rsa_pub_key> const & a,
106 base64<rsa_priv_key> const & b)
107 : pub(a), priv(b)
108 {}
109};
110
111// fs::path is our "generic" safe path type, pointing potentially anywhere
112// in the filesystem. if you want to *define* or work with any of these you
113// need to include boost/filesystem/path.hpp.
114
115namespace boost { namespace filesystem { class path; } }
116namespace fs = boost::filesystem;
117
118// diff type
119enum diff_type
120{
121 unified_diff,
122 context_diff,
123 external_diff
124};
125
126// do these belong here?
127inline bool
128null_id(hexenc<id> const & i)
129{
130 return i().empty();
131}
132
133inline bool
134null_id(file_id const & i)
135{
136 return i.inner()().empty();
137}
138
139inline bool
140null_id(manifest_id const & i)
141{
142 return i.inner()().empty();
143}
144
145inline bool
146null_id(revision_id const & i)
147{
148 return i.inner()().empty();
149}
150
151
152// Local Variables:
153// mode: C++
154// fill-column: 76
155// c-file-style: "gnu"
156// indent-tabs-mode: nil
157// End:
158// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
159
160#endif // __VOCAB_HH__

Archive Download this file

Branches

Tags

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