69 if (raw_orig_pages.empty()) {
78 char c = orig_pages[pos];
79 if (c >=
'0' && c <=
'9') {
80 if (digit_pos ==
NPOS) {
82 }
else if (letter_pos > digit_pos && letter_pos !=
NPOS) {
85 }
else if ((c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z')) {
86 if (letter_pos ==
NPOS) {
88 }
else if (digit_pos > letter_pos && digit_pos !=
NPOS) {
91 }
else if (c ==
'-' && digit_pos !=
NPOS && hyphen_pos ==
NPOS) {
93 lhs_digit_pos = digit_pos;
94 lhs_letter_pos = letter_pos;
95 digit_pos = letter_pos =
NPOS;
102 if (lhs == orig_pages.
substr(hyphen_pos + 1)) {
106 if (lhs_letter_pos > 0 && lhs_letter_pos !=
NPOS) {
111 if (lhs_letter_pos == hyphen_pos - 1
112 && letter_pos == hyphen_pos + 1
113 && orig_pages.
size() == letter_pos + 1) {
114 int diff = orig_pages[letter_pos] - orig_pages[lhs_letter_pos];
117 }
else if (diff > 0) {
118 string result(orig_pages, 0, letter_pos);
119 result.append(orig_pages, 0, lhs_letter_pos);
120 result += orig_pages[letter_pos];
124 }
else if (letter_pos ==
NPOS && digit_pos !=
NPOS) {
129 CTempString lhs_digits(lhs, lhs_digit_pos), rhs(orig_pages, digit_pos);
132 }
else if (lhs_digits.size() >= rhs.
size()) {
134 if (lhs.
substr(lhs_tail_pos) < rhs) {
135 string result(orig_pages, 0, hyphen_pos + 1);
136 result.append(lhs, 0, lhs_tail_pos);
140 }
else if (lhs_letter_pos !=
NPOS
141 && rhs.
size() > hyphen_pos - lhs_digit_pos) {
144 string result(orig_pages, 0, hyphen_pos + 1);
162 && date.
GetStr() !=
"?") {
163 return '(' + date.
GetStr().substr(0, 4) +
')';
174 const string* issue =
ip.CanGetIssue() ? &
ip.GetIssue() :
NULL;
175 const string* part_sup =
ip.CanGetPart_sup() ? &
ip.GetPart_sup() :
NULL;
176 const string* part_supi =
ip.CanGetPart_supi() ? &
ip.GetPart_supi() :
NULL;
189 *
label +=
' ' + *part_supi;
203 const string* title1,
204 const string* title2,
205 const string* titleunique,
207 const string* volume,
212 const string* part_sup = 0;
213 const string* part_supi = 0;
234 *
label +=
'(' + *date +
") ";
237 if (title && !titleunique) {
240 }
catch (exception&) {}
243 if (title && !title2) {
246 }
catch (exception&) {}
251 *
label +=
"(in) " + *title2 +
" ";
253 *
label += *title1 + *title2 +
" ";
256 *
label += *title2 +
" ";
262 *
label += *volume + *part_sup +
":";
265 *
label += *volume +
":";
271 *
label +=
"(" + *issue + *part_supi +
")";
274 *
label +=
"(" + *issue +
")";
283 *
label +=
"Unpublished";
293 if (titleunique && !titleunique->empty()) {
298 while ( (is >> word) && (
cnt++ < 40) ) {
User-defined methods of the data storage class.
"Mix-in" interfaces to implement GetLabel for CCit_* et al.
@Auth_list.hpp User-defined methods of the data storage class.
void GetDate(string *label, bool year_only=false) const
Append a standardized string representation of the date to the label.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
const string & GetTitle(C_E::E_Choice type=C_E::e_not_set) const
If the internal list contains a title (of the specified type, if given), returns the corresponding st...
@ eLabel_V1
Traditional GetLabel semantics, modeled on the C Toolkit's PubLabelUnique.
@ eLabel_V2
New implementation, in line with GenBank/GenPept REFERENCE JOURNAL fields and the like.
@ eLabel_MaxVersion
Maximum supported version.
@ eLabel_DefaultVersion
Current default version.
int TLabelFlags
binary OR of ELabelFlags
static string GetParenthesizedYear(const CDate &date)
virtual bool GetLabelV2(string *label, TLabelFlags flags) const =0
virtual bool GetLabelV1(string *label, TLabelFlags flags) const =0
static string FixPages(const string &orig_pages)
Canonicalize a range of page numbers, expanding Medline-style 125-35 -> 125-135, F124-34 -> F124-F134...
static bool HasText(const string &s)
static void NoteSup(string *label, const CImprint &imp)
static bool x_GetLabelV1(string *label, bool unique, const CAuth_list *authors, const CImprint *imprint, const CTitle *title, const CCit_book *book, const CCit_jour *journal, const string *title1=0, const string *title2=0, const string *titleunique=0, const string *date=0, const string *volume=0, const string *issue=0, const string *pages=0, bool unpublished=false)
bool GetLabel(string *label, TLabelFlags flags=0, ELabelVersion version=eLabel_DefaultVersion) const override
Append a label to the specified string per the specified flags.
static void MaybeAddSpace(string *label)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Warning(CExceptionArgs_Base &args)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
static CTempString TruncateSpaces_Unsafe(const CTempString str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
CTempString & assign(const char *src_str, size_type len)
Assign new values to the content of the a string.
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
size_type find_first_not_of(const CTempString match, size_type pos=0) const
Find the first occurrence of any character not in the matching string within the current string,...
size_type find_first_of(const CTempString match, size_type pos=0) const
Find the first occurrence of any character in the matching string within the current string,...
size_type size(void) const
Return the length of the represented array.
static const size_type npos
static const char label[]
bool IsSetVolume(void) const
Check if a value has been assigned to Volume data member.
const TPart_supi & GetPart_supi(void) const
Get the Part_supi member data.
const TVolume & GetVolume(void) const
Get the Volume member data.
const TPages & GetPages(void) const
Get the Pages member data.
const TIssue & GetIssue(void) const
Get the Issue member data.
const TPart_sup & GetPart_sup(void) const
Get the Part_sup member data.
bool IsSetIssue(void) const
Check if a value has been assigned to Issue data member.
bool IsSetPart_sup(void) const
part/sup of volume Check if a value has been assigned to Part_sup data member.
const TDate & GetDate(void) const
Get the Date member data.
bool IsSetPart_supi(void) const
part/sup on issue Check if a value has been assigned to Part_supi data member.
bool IsSetPages(void) const
Check if a value has been assigned to Pages data member.
bool IsStd(void) const
Check if variant Std is selected.
const TStr & GetStr(void) const
Get the variant data.
bool IsStr(void) const
Check if variant Str is selected.