(bookRef.GetBookname().substr(0, 3) ==
"NBK");
75 static const stringsection(
"section");
76 static const stringslash(
"/"), suffix(
"/pmc[rid]"), orString(
"%20OR%20"), dummyElement(
"DUMMY_ELEMENT");
78 booldistinctSubelement;
81 stringbookname, elementType, elementId, subelementId;
82bookname = elementType = elementId = subelementId =
kEmptyStr;
91 CRegexpregexpSection(
"(.*)&part=(.*)$");
92 CRegexpregexpSectionWithSubelement(
"(.*)&part=(.*)#(.*)");
93 CRegexpregexpRendertype(
"(.*)&part=(.*)&rendertype=(.*)&id=(.*)");
96bookname = regexpRendertype.
GetSub(brfcgiBookTerm, 1);
97elementType = regexpRendertype.
GetSub(brfcgiBookTerm, 3);
98elementId = regexpRendertype.
GetSub(brfcgiBookTerm, 2);
99subelementId = regexpRendertype.
GetSub(brfcgiBookTerm, 4);
100}
else if(regexpSectionWithSubelement.
GetMatch(brfcgiBookTerm).
length() > 0) {
101bookname = regexpSectionWithSubelement.
GetSub(brfcgiBookTerm, 1);
102elementType = section;
103elementId = regexpSectionWithSubelement.
GetSub(brfcgiBookTerm, 2);
104subelementId = regexpSectionWithSubelement.
GetSub(brfcgiBookTerm, 3);
105}
else if(regexpSection.
GetMatch(brfcgiBookTerm).
length() > 0) {
106bookname = regexpSection.
GetSub(brfcgiBookTerm, 1);
107elementType = section;
108elementId = regexpSection.
GetSub(brfcgiBookTerm, 2);
111distinctSubelement = (subelementId.length() > 0 && subelementId != elementId);
113 if(elementType ==
"glossary") {
114elementType =
"def-item";
115}
else if(elementType.substr(0, 3) ==
"app") {
116elementType =
"appendix";
117}
else if(elementType.substr(0, 3) ==
"box") {
118elementType =
"box";
119}
else if(elementType.substr(0, 3) ==
"fig") {
120elementType =
"figgrp";
121}
else if(elementType.substr(0, 3) ==
"sec"|| elementType ==
"unassigned") {
122elementType =
"sec";
123}
else if(elementType.substr(0, 5) ==
"table") {
124elementType =
"table";
128 if(elementType.length() > 0) {
130 if(distinctSubelement) {
131baseTerm = bookname + slash + elementId + slash + dummyElement + slash + subelementId + suffix;
133baseTerm = bookname + slash + dummyElement + slash + elementId + suffix;
138 if(forceOR || elementType ==
"book-part") {
139term =
NStr::Replace(baseTerm, dummyElement,
"sec") + orString;
140term +=
NStr::Replace(baseTerm, dummyElement,
"chapter") + orString;
141term +=
NStr::Replace(baseTerm, dummyElement,
"figgrp") + orString;
142term +=
NStr::Replace(baseTerm, dummyElement,
"table") + orString;
170 stringelementid, subelementid, typeString;
174 result=
"unexpected book_ref format: neither elementid nor celementid is set";
177 result=
"unexpected book_ref format: both elementid and celementid are set";
180 result=
"unexpected book_ref format: both subelementid and csubelementid are set";
193typeString = (allowedElements) ? allowedElements->
FindName(bookRef.
GetTextelement(),
true) :
"unassigned";
198 _ASSERT(bookname.length() + elementid.length() + subelementid.length() + 15 < 2048);
200 if(subelementid.size() > 0)
201sprintf(
buf,
"%s.%s.%s#%s", bookname.c_str(), typeString.c_str(), elementid.c_str(), subelementid.c_str());
203sprintf(
buf,
"%s.%s.%s", bookname.c_str(), typeString.c_str(), elementid.c_str());
214 stringelementid, subelementid, renderType;
218 result=
"unexpected book_ref format: neither elementid nor celementid is set";
221 result=
"unexpected book_ref format: both elementid and celementid are set";
224 result=
"unexpected book_ref format: both subelementid and csubelementid are set";
255 result= bookname +
"&part="+ part;
264renderType =
"figure";
267renderType =
"def-item";
268}
else if(allowedElements) {
269renderType = allowedElements->
FindName(elementType,
true);
271 if(renderType.length() == 0) {
272renderType =
"unassigned";
275 if(
id.length() == 0) {
278 result= bookname +
"&part="+ part +
"&rendertype="+ renderType +
"&id="+ id;
281 result= bookname +
"&part="+ part;
282 if(
id.
size() > 0)
298 stringidStr, renderType;
316renderType =
"figure";
318renderType =
"def-item";
320renderType = allowedElements->
FindName(elementType,
true);
322 if(renderType.length() > 0)
323 result+=
"/"+ renderType +
"/"+ idStr;
324 else if(idStr.length() > 0)
327}
else if(idStr.length() > 0) {
337 stringbookname, address, subaddress, typeStr, firstTokenStr;
338list<string> sharpTokens;
339 CRegexpregexpCommon(
"book=(.*)&part=(.*)");
340 CRegexpregexpRendertype(
"&part=(.*)&rendertype=(.*)&id=(.*)");
346 if(sharpTokens.size() == 1 || sharpTokens.size() == 2) {
347 boolhaveSubaddr = (sharpTokens.size() == 2);
350firstTokenStr = sharpTokens.front();
352 if(regexpCommon.
NumFound() == 3) {
354bookname = regexpCommon.
GetSub(firstTokenStr, 1);
357 if(regexpRendertype.
NumFound() == 4) {
358address = regexpRendertype.
GetSub(firstTokenStr, 1);
359typeStr = regexpRendertype.
GetSub(firstTokenStr, 2);
363 if(typeStr ==
"figure")
365 else if(typeStr ==
"def-item")
366typeStr =
"glossary";
368 if(allowedElements && !allowedElements->
IsValidName(typeStr)) {
371subaddress = regexpRendertype.
GetSub(firstTokenStr, 3);
374address = regexpCommon.
GetSub(firstTokenStr, 2);
380subaddress = sharpTokens.back();
382subaddress =
"A"+ subaddress;
388 if(typeStr.length() > 0 && allowedElements) {
392bookRef->SetBookname(bookname);
393bookRef->SetTextelement(typeEnum);
394bookRef->SetCelementid(address);
395 if(subaddress.length() > 0) {
396bookRef->SetCsubelementid(subaddress);
420 stringbaseStr, nbkCode, idStr;
422 CRegexpregexpBase(
"/books/(NBK.+)");
423 CRegexpregexpNBK(
"^(NBK[^/]+)");
424 CRegexpregexpRendertype(
"^NBK[^/]+/(.+)/(.+)");
428 stringurlPath = url.
GetPath();
433urlPath = urlPath.substr(0, urlPath.length() - 1);
439baseStr = regexpBase.
GetSub(urlPath, 1);
440nbkCode = regexpNBK.
GetMatch(baseStr);
443 if(regexpRendertype.
NumFound() == 3) {
444typeStr = regexpRendertype.
GetSub(baseStr, 1);
445idStr = regexpRendertype.
GetSub(baseStr, 2);
448typeStr = urlArgs.
GetValue(
"rendertype");
450}
else if(urlFrag.length() > 0) {
452typeStr =
"section";
454}
else if(urlFrag.length() == 0) {
457typeStr =
"chapter";
462 if(nbkCode.length() > 0) {
467 if(typeStr ==
"figure")
469 else if(typeStr ==
"def-item")
470typeStr =
"glossary";
476 if(allowedElements && allowedElements->
IsValidName(typeStr)) {
485bookRef->SetBookname(nbkCode);
486bookRef->SetTextelement(typeEnum);
487bookRef->SetCelementid(idStr);
User-defined methods of the data storage class.
string CCddBookRefToEsearchTerm(const CCdd_book_ref &bookRef)
string CCddBookRefToString(const CCdd_book_ref &bookRef)
bool BrBookURLToCCddBookRef(const string &brBookUrl, CRef< CCdd_book_ref > &bookRef)
string CCddBookRefToBvString(const CCdd_book_ref &bookRef)
bool IsPortalDerivedBookRef(const CCdd_book_ref &bookRef)
bool PortalBookURLToCCddBookRef(const string &portalBookUrl, CRef< CCdd_book_ref > &bookRef)
string BrFcgiBookTermToEutilsTerm(const string &brfcgiBookTerm, bool forceOR)
string CCddBookRefToPortalString(const CCdd_book_ref &bookRef)
string CCddBookRefToBrString(const CCdd_book_ref &bookRef)
const string & FindName(TEnumValueType value, bool allowBadValue) const
Find name of the enum by its numeric value.
bool IsValidName(const CTempString &name) const
Check whether enum with this name is defined.
TEnumValueType FindValue(const CTempString &name) const
Find numeric value by the name of the enum.
void Reset(void)
Reset reference object.
bool Empty(void) const THROWS_NONE
Check if CRef is empty â not pointing to any object, which means having a null value.
CTempString GetSub(CTempString str, size_t idx=0) const
Get pattern/subpattern from previous GetMatch().
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
int NumFound() const
Get number of patterns + subpatterns.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static unsigned long StringToULong(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned long.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
size_type length(void) const
Return the length of the represented array.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string.
@ fConvErr_NoThrow
Do not throw an exception on error.
const CUrlArgs & GetArgs(void) const
Get const list of arguments.
const string & GetFragment(void) const
bool IsSetValue(const string &name) const
Check if an argument with the given name exists.
const string & GetPath(void) const
const string & GetValue(const string &name, bool *is_found=0) const
Get value for the given name.
const TBookname & GetBookname(void) const
Get the Bookname member data.
bool IsSetCsubelementid(void) const
exact address, if character string Check if a value has been assigned to Csubelementid data member.
bool IsSetCelementid(void) const
address of the text element, if character string Check if a value has been assigned to Celementid dat...
bool IsSetElementid(void) const
numerical address of the text-element Check if a value has been assigned to Elementid data member.
const TCelementid & GetCelementid(void) const
Get the Celementid member data.
TTextelement GetTextelement(void) const
Get the Textelement member data.
bool IsSetSubelementid(void) const
exact address, used with section Check if a value has been assigned to Subelementid data member.
TElementid GetElementid(void) const
Get the Elementid member data.
const TCsubelementid & GetCsubelementid(void) const
Get the Csubelementid member data.
TSubelementid GetSubelementid(void) const
Get the Subelementid member data.
@ eTextelement_figgrp
a figure or set of figures
@ eTextelement_unassigned
type of element
@ eTextelement_section
a section or paragraph
@ eTextelement_chapter
a whole chapter
@ eTextelement_glossary
glossary
const struct ncbi::grid::netcache::search::fields::SIZE size
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4