monotone

monotone Mtn Source Tree

Root/rev_height.hh

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