| 1 |
|
/* |
| 2 |
|
Copyright 2002 Cyril Picard |
| 3 |
|
|
| 4 |
|
This file is part of the GEDCOMParser library |
| 5 |
|
(developed within the Genealogy Free Software Tools project). |
| 6 |
|
|
| 7 |
|
The GEDCOMParser library is free software; you can redistribute it and/or modify |
| 8 |
|
it under the terms of the GNU General Public License as published by |
| 9 |
|
the Free Software Foundation; either version 2 of the License, or |
| 10 |
|
(at your option) any later version. |
| 11 |
|
|
| 12 |
|
The GEDCOMParser library is distributed in the hope that it will be useful, |
| 13 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
|
GNU General Public License for more details. |
| 16 |
|
|
| 17 |
|
You should have received a copy of the GNU General Public License |
| 18 |
|
along with the GEDCOMParser library ; if not, write to the Free Software |
| 19 |
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
|
|
| 21 |
|
*/ |
| 22 |
|
|
| 23 |
|
#ifndef _GEDCOMPARSER_DATEMANAGEMENT_DATEVALUE_HH_ |
| 24 |
|
#define _GEDCOMPARSER_DATEMANAGEMENT_DATEVALUE_HH_ |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
#include "GEDCOMParser/DateManagement/Date.hh" |
| 28 |
|
#include "GEDCOMParser/DateManagement/DatePhrase.hh" |
| 29 |
|
#include "GEDCOMParser/DateManagement/Range.hh" |
| 30 |
|
#include "GEDCOMParser/DateManagement/Period.hh" |
| 31 |
|
#include <string> |
| 32 |
|
|
| 33 |
|
/// Package GEDCOMParser |
| 34 |
|
namespace GEDCOMParser |
| 35 |
|
{ |
| 36 |
|
/// Implements the dates management (essentially parsing) in GEDCOM files |
| 37 |
|
namespace DateManagement |
| 38 |
|
{ |
| 39 |
|
/** @memo Implements the GEDCOM 5.5 DATE_VALUE primitive element |
| 40 |
|
**/ |
| 41 |
|
class DateValue |
| 42 |
|
{ |
| 43 |
|
public: |
| 44 |
|
/// @memo Implements the range types enumeration (typedef'd to enumRangeTypes) |
| 45 |
|
enum _enumDateValueTypes |
| 46 |
|
{ |
| 47 |
|
/// |
| 48 |
|
e_Null, |
| 49 |
|
/// |
| 50 |
|
e_Date, |
| 51 |
|
/// |
| 52 |
|
e_DatePhrase, |
| 53 |
|
/// |
| 54 |
|
e_Range, |
| 55 |
|
/// |
| 56 |
|
e_Period, |
| 57 |
|
/// |
| 58 |
|
e_Interpreted |
| 59 |
|
}; |
| 60 |
|
typedef enum _enumDateValueTypes enumDateValueTypes; |
| 61 |
|
DateValue(void) : |
| 62 |
|
_parsing_ko(true), |
| 63 |
|
_raw_value(), |
| 64 |
|
_type(e_Null), |
| 65 |
|
_date(0), |
| 66 |
|
_date_phrase(0), |
| 67 |
|
_period(0), |
| 68 |
|
_range(0) |
| 69 |
|
{ |
| 70 |
|
return; |
| 71 |
|
}; |
| 72 |
|
DateValue(DateValue const &d) : |
| 73 |
|
_parsing_ko(d._parsing_ko), |
| 74 |
|
_raw_value(d._raw_value), |
| 75 |
|
_type(d._type), |
| 76 |
|
_date(0), |
| 77 |
|
_date_phrase(0), |
| 78 |
|
_period(0), |
| 79 |
|
_range(0) |
| 80 |
|
{ |
| 81 |
|
if (d._date != 0) |
| 82 |
|
_date = new GEDCOMParser::DateManagement::Date(*d._date); |
| 83 |
|
if (d._date_phrase != 0) |
| 84 |
|
_date_phrase = new GEDCOMParser::DateManagement::DatePhrase(*d._date_phrase); |
| 85 |
|
if (d._period != 0) |
| 86 |
|
_period = new GEDCOMParser::DateManagement::Period(*d._period); |
| 87 |
|
if (d._range != 0) |
| 88 |
|
_range = new GEDCOMParser::DateManagement::Range(*d._range); |
| 89 |
|
return; |
| 90 |
|
}; |
| 91 |
|
DateValue(std::string const &value); |
| 92 |
|
~DateValue(void) |
| 93 |
|
{ |
| 94 |
|
delete _date; _date = 0; |
| 95 |
|
delete _date_phrase; _date_phrase = 0; |
| 96 |
|
delete _period; _period = 0; |
| 97 |
|
delete _range; _range = 0; |
| 98 |
|
}; |
| 99 |
|
///@name Accessors (set) |
| 100 |
|
//@{ |
| 101 |
|
/// |
| 102 |
|
void setType(enumDateValueTypes type); |
| 103 |
|
/// |
| 104 |
|
void setDate(GEDCOMParser::DateManagement::Date const &date); |
| 105 |
|
/// |
| 106 |
|
void setDatePhrase(GEDCOMParser::DateManagement::DatePhrase const &date_phrase); |
| 107 |
|
/// |
| 108 |
|
void setPeriod(GEDCOMParser::DateManagement::Period const &period); |
| 109 |
|
/// |
| 110 |
|
void setRange(GEDCOMParser::DateManagement::Range const &range); |
| 111 |
|
/// |
| 112 |
|
void setValue(std::string const &value); |
| 113 |
|
/// |
| 114 |
|
void setParseError(bool); |
| 115 |
|
//@} |
| 116 |
|
|
| 117 |
|
///@name Accessors (get) |
| 118 |
|
//@{ |
| 119 |
|
/// |
| 120 |
|
std::string const getDisplayValue(void) const; |
| 121 |
|
//@} |
| 122 |
|
private: |
| 123 |
|
bool _parsing_ko; |
| 124 |
|
std::string _raw_value; |
| 125 |
|
enumDateValueTypes _type; |
| 126 |
|
GEDCOMParser::DateManagement::Date * _date; |
| 127 |
|
GEDCOMParser::DateManagement::DatePhrase * _date_phrase; |
| 128 |
|
GEDCOMParser::DateManagement::Period * _period; |
| 129 |
|
GEDCOMParser::DateManagement::Range * _range; |
| 130 |
|
}; |
| 131 |
|
}; |
| 132 |
|
}; |
| 133 |
|
|
| 134 |
|
#endif |