| 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 |
|
#include "GEDCOMParser/DateManagement/Range.hh" |
| 24 |
|
|
| 25 |
|
#ifdef HAVE_CONFIG_H |
| 26 |
|
#include "config.h" |
| 27 |
|
#endif // HAVE_CONFIG_H |
| 28 |
|
|
| 29 |
|
#include "gettext.h" |
| 30 |
|
#define _(String) dgettext(PACKAGE, String) |
| 31 |
|
|
| 32 |
|
void GEDCOMParser::DateManagement::Range::setType(enumRangeTypes type) |
| 33 |
|
{ |
| 34 |
|
_type = type; |
| 35 |
|
return; |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
void GEDCOMParser::DateManagement::Range::setBound1(GEDCOMParser::DateManagement::Date const &bound1) |
| 39 |
|
{ |
| 40 |
|
if ((_bound1 != 0) && (_bound1 != &bound1)) |
| 41 |
|
{ |
| 42 |
|
delete _bound1; _bound1 != 0; |
| 43 |
|
} |
| 44 |
|
if (_bound1 != &bound1) |
| 45 |
|
{ |
| 46 |
|
_bound1 = new GEDCOMParser::DateManagement::Date(bound1); |
| 47 |
|
} |
| 48 |
|
return; |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
void GEDCOMParser::DateManagement::Range::setBound2(GEDCOMParser::DateManagement::Date const &bound2) |
| 52 |
|
{ |
| 53 |
|
if ((_bound2 != 0) && (_bound2 != &bound2)) |
| 54 |
|
{ |
| 55 |
|
delete _bound2; _bound2 != 0; |
| 56 |
|
} |
| 57 |
|
if (_bound2 != &bound2) |
| 58 |
|
{ |
| 59 |
|
_bound2 = new GEDCOMParser::DateManagement::Date(bound2); |
| 60 |
|
} |
| 61 |
|
return; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
std::string const GEDCOMParser::DateManagement::Range::getDisplayValue(void) const |
| 65 |
|
{ |
| 66 |
|
std::string res; |
| 67 |
|
switch(_type) |
| 68 |
|
{ |
| 69 |
|
case e_Before: |
| 70 |
|
if (_bound1 != 0) |
| 71 |
|
{ |
| 72 |
|
res = _("Before ") + _bound1->getDisplayValue(); |
| 73 |
|
} |
| 74 |
|
break; |
| 75 |
|
case e_After: |
| 76 |
|
if (_bound1 != 0) |
| 77 |
|
{ |
| 78 |
|
res = _("After ") + _bound1->getDisplayValue(); |
| 79 |
|
} |
| 80 |
|
break; |
| 81 |
|
case e_Between: |
| 82 |
|
if (_bound1 != 0) |
| 83 |
|
{ |
| 84 |
|
res = _("Between ") + _bound1->getDisplayValue(); |
| 85 |
|
} |
| 86 |
|
if (_bound2 != 0) |
| 87 |
|
{ |
| 88 |
|
res = res + _(" and ") + _bound2->getDisplayValue(); |
| 89 |
|
} |
| 90 |
|
break; |
| 91 |
|
default: |
| 92 |
|
res = _("Unknown range "); |
| 93 |
|
break; |
| 94 |
|
} |
| 95 |
|
return res; |
| 96 |
|
} |