Line data Source code
1 : // Copyright (c) 2023 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // https://snapwebsites.org/project/versiontheca
4 : // contact@m2osw.com
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 3 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, see <https://www.gnu.org/licenses/>.
18 : #pragma once
19 :
20 : /** \file
21 : * \brief Trait used to parse and compare roman versions.
22 : *
23 : * The trait allows the version numbers to be written in roman numerals.
24 : *
25 : * \li I -- represents 1
26 : * \li V -- represents 5
27 : * \li X -- represents 10
28 : * \li L -- represents 50
29 : * \li C -- represents 100
30 : * \li D -- represents 500
31 : * \li M -- represents 1000
32 : *
33 : * The parser understands many syntaxes, but in most cases you want to use
34 : * the "subtract one" version instead of the "four of this" syntax. So to
35 : * write the roman numeral 4, you want to use IV instead of IIII.
36 : *
37 : * The parser ignores case, so ix and IX both represent 9.
38 : */
39 :
40 : // self
41 : //
42 : #include <versiontheca/trait.h>
43 :
44 :
45 : namespace versiontheca
46 : {
47 :
48 :
49 :
50 : part_integer_t from_roman_number(std::string const & value);
51 : std::string to_roman_number(part_integer_t value);
52 :
53 :
54 :
55 8030 : class roman
56 : : public trait
57 : {
58 : public:
59 : typedef std::shared_ptr<roman> pointer_t;
60 :
61 : virtual bool parse(std::string const & v) override;
62 : virtual std::string to_string() const override;
63 : };
64 :
65 :
66 :
67 : }
68 : // namespace versiontheca
69 : // vim: ts=4 sw=4 et
|