00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 #ifndef BOSS_NUMBERS_H
00026 #define BOSS_NUMBERS_H
00027 #include "boss_utility/boss_types.h"
00028 #include <fstream>
00029 #include <set>
00030 #include <iterator>
00031
00036
00037
00038 struct NW_mapper
00039 {
00040 unsigned length;
00041 string number;
00042 string n_word;
00043 string n_tra;
00044 NW_mapper() {;}
00045 NW_mapper(unsigned l, string n, string w, string t) : length(l), number(n), n_word(w), n_tra(t) {;}
00046 };
00047
00048
00049 typedef vector<struct NW_mapper> NW_Vector;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 class BOSS_Numbers {
00060 protected:
00061 NW_Vector table;
00062 set<string> specials;
00063
00064 virtual BOSS::t_SSPair patch(BOSS::t_SSPair number, BOSS::t_SSPair name) const;
00065 virtual BOSS::t_SSPair get_number(const string& input_number) const;
00066 virtual BOSS::t_SSPair get_name(const unsigned& length) const;
00067 virtual BOSS::t_SSPair convert(string input_number) const;
00068
00069 public:
00070 virtual BOSS::t_SSPair roman(const string& input) const = 0;
00071 virtual BOSS::t_SSPair operator () (string input_number) const = 0;
00072 BOSS_Numbers() {};
00073 virtual ~BOSS_Numbers() {};
00074 };
00075
00076
00077
00079 inline istream & operator >> (istream & in, NW_mapper & m) {
00080 return in >> m.length >> m.number >> m.n_word >> m.n_tra;
00081 }
00082
00083 inline ostream & operator << (ostream & out, const NW_mapper & m) {
00084 return out << m.length << " " << m.number << " " << m.n_word << " " << m.n_tra;
00085 }
00086
00088 inline istream & operator >> (istream & in, NW_Vector & v) {
00089 copy(istream_iterator< NW_mapper >(in), istream_iterator< NW_mapper >(), back_inserter(v));
00090 return in;
00091 }
00092
00093 inline ostream & operator << (ostream & out, const NW_Vector & v) {
00094 copy(v.begin(), v.end(), ostream_iterator< NW_mapper >(out, "\n"));
00095 return out;
00096 }
00097
00098
00099 inline BOSS::t_SSPair operator + (BOSS::t_SSPair a, const BOSS::t_SSPair& b) {
00100 a.first=a.first+b.first;
00101 a.second=a.second+b.second;
00102 return a;
00103 }
00104
00105
00106 inline void operator += (BOSS::t_SSPair& a, const BOSS::t_SSPair& b) {
00107 a=a+b;
00108 }
00109
00110 #endif