monotone

monotone Mtn Source Tree

Root/rev_height.hh

1#ifndef __REV_HEIGHT_HH_
2#define __REV_HEIGHT_HH_
3
4// Copyright (C) 2006 Thomas Moschny <thomas.moschny@gmx.de>
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 <iosfwd>
14#include <string>
15#include "numeric_vocab.hh"
16
17class rev_height
18{
19 std::string d;
20
21public:
22 rev_height() : d() {}
23 rev_height(rev_height const & other) : d(other.d) {}
24 explicit rev_height(std::string const & s) : d(s) {}
25 std::string const & operator()() const { return d; }
26
27 rev_height child_height(u32 nr) const;
28 static rev_height root_height();
29
30 bool valid() const { return d.size() > 0; }
31
32 bool operator ==(rev_height const & other) const
33 {
34 return this->d == other.d;
35 }
36 bool operator < (rev_height const & other) const
37 {
38 return this->d < other.d;
39 }
40 bool operator !=(rev_height const & other) const
41 {
42 return this->d != other.d;
43 }
44 bool operator > (rev_height const & other) const
45 {
46 return this->d > other.d;
47 }
48 bool operator <=(rev_height const & other) const
49 {
50 return this->d <= other.d;
51 }
52 bool operator >=(rev_height const & other) const
53 {
54 return this->d >= other.d;
55 }
56};
57
58std::ostream & operator <<(std::ostream & os, rev_height const & h);
59void dump(rev_height const & h, std::string & out);
60
61#endif // __REV_HEIGHT_HH_
62
63// Local Variables:
64// mode: C++
65// fill-column: 76
66// c-file-style: "gnu"
67// indent-tabs-mode: nil
68// End:
69// 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