NCBI C++ ToolKit
cuBookRefUtils.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: cuBookRefUtils.cpp 69943 2015-11-23 17:04:08Z lanczyck $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Chris Lanczycki
27  *
28  * File Description:
29  *
30  * Various utility functions for working with CCdd_book_ref objects
31  *
32  * ===========================================================================
33  */
34 
35 #include <ncbi_pch.hpp>
36 #include <serial/enumvalues.hpp>
37 #include <util/xregexp/regexp.hpp>
38 #include <util/ncbi_url.hpp>
41 
42 
44 BEGIN_SCOPE(cd_utils)
45 
46 
48 {
49  // 'bookname' is a mandatory CCdd_book_ref element.
50  return (bookRef.GetBookname().substr(0, 3) == "NBK");
51 }
52 
53 string CCddBookRefToString(const CCdd_book_ref& bookRef)
54 {
55  if (IsPortalDerivedBookRef(bookRef)) {
56  return CCddBookRefToPortalString(bookRef);
57  } else {
58  return CCddBookRefToBrString(bookRef);
59  }
60 }
61 
62 
63 // Adapted from CDTree.
64 // Notes on doing esearch queries of the bookshelf:
65 // 1) when have subelement, term is something like this:
66 // eurekah/A17112/sec/A17113/pmc[rid]
67 // 2) when there is no m_parsedSubelementId (or it is equal to m_parsedElement),
68 // a slightly different format is used:
69 // eurekah/chapter/A17112/pmc
70 // 3) the esearch.fcgi 'term' allows 'OR' constructs for when it's not clear
71 // what the esearchType should be. E.g., with '%20' being a URL-encoded space,
72 // cmed6/sec/A41564/pmc[rid]%20OR%20cmed6/chapter/A41564/pmc[rid]%20or%20cmed6/part/A41564/pmc[rid]
73 string BrFcgiBookTermToEutilsTerm(const string& brfcgiBookTerm, bool forceOR)
74 {
75  static const string section("section");
76  static const string slash("/"), suffix("/pmc[rid]"), orString("%20OR%20"), dummyElement("DUMMY_ELEMENT");
77 
78  bool distinctSubelement;
79  string term = kEmptyStr;
80  string baseTerm;
81  string bookname, elementType, elementId, subelementId;
82  bookname = elementType = elementId = subelementId = kEmptyStr;
83 
84  // Assumed format for a 'br.fcgi' derived book reference:
85  // figure/table
86  // bookname&part=part&rendertype=rendertype&id=id;
87  //
88  // everything else is treated as a 'section'
89  // bookname&part=part[#id]
90 
91  CRegexp regexpSection("(.*)&part=(.*)$");
92  CRegexp regexpSectionWithSubelement("(.*)&part=(.*)#(.*)");
93  CRegexp regexpRendertype("(.*)&part=(.*)&rendertype=(.*)&id=(.*)");
94 
95  if (regexpRendertype.GetMatch(brfcgiBookTerm).length() > 0) {
96  bookname = regexpRendertype.GetSub(brfcgiBookTerm, 1);
97  elementType = regexpRendertype.GetSub(brfcgiBookTerm, 3); // element type
98  elementId = regexpRendertype.GetSub(brfcgiBookTerm, 2); // element id
99  subelementId = regexpRendertype.GetSub(brfcgiBookTerm, 4);
100  } else if (regexpSectionWithSubelement.GetMatch(brfcgiBookTerm).length() > 0) {
101  bookname = regexpSectionWithSubelement.GetSub(brfcgiBookTerm, 1);
102  elementType = section;
103  elementId = regexpSectionWithSubelement.GetSub(brfcgiBookTerm, 2); // element id
104  subelementId = regexpSectionWithSubelement.GetSub(brfcgiBookTerm, 3);
105  } else if (regexpSection.GetMatch(brfcgiBookTerm).length() > 0) {
106  bookname = regexpSection.GetSub(brfcgiBookTerm, 1);
107  elementType = section;
108  elementId = regexpSection.GetSub(brfcgiBookTerm, 2); // element id
109  }
110 
111  distinctSubelement = (subelementId.length() > 0 && subelementId != elementId);
112 
113  if (elementType == "glossary") {
114  elementType = "def-item";
115  } else if (elementType.substr(0, 3) == "app") {
116  elementType = "appendix";
117  } else if (elementType.substr(0, 3) == "box") {
118  elementType = "box";
119  } else if (elementType.substr(0, 3) == "fig") {
120  elementType = "figgrp";
121  } else if (elementType.substr(0, 3) == "sec" || elementType == "unassigned") {
122  elementType = "sec";
123  } else if (elementType.substr(0, 5) == "table") {
124  elementType = "table";
125  }
126 
127 
128  if (elementType.length() > 0) {
129 
130  if (distinctSubelement) {
131  baseTerm = bookname + slash + elementId + slash + dummyElement + slash + subelementId + suffix;
132  } else {
133  baseTerm = bookname + slash + dummyElement + slash + elementId + suffix;
134  }
135 
136  // need to use the 'OR' syntax since we don't know what this is;
137  // try 'sec', 'chapter', 'part', 'figgrp', 'table'
138  if (forceOR || elementType == "book-part") {
139  term = NStr::Replace(baseTerm, dummyElement, "sec") + orString;
140  term += NStr::Replace(baseTerm, dummyElement, "chapter") + orString;
141  term += NStr::Replace(baseTerm, dummyElement, "figgrp") + orString;
142  term += NStr::Replace(baseTerm, dummyElement, "table") + orString;
143  term += NStr::Replace(baseTerm, dummyElement, "part");
144  } else {
145  term = NStr::Replace(baseTerm, dummyElement, elementType);
146  }
147 
148  }
149 
150  return term;
151 }
152 
154 {
155  string term;
156  if (IsPortalDerivedBookRef(bookRef)) {
157  string portalBookTerm = CCddBookRefToPortalString(bookRef);
158  term = NStr::Replace(portalBookTerm, "/#", "/");
159  } else {
160  // transform brBookTerm (as per CDTree's BrFcgiBookTermToXMLViaEutils)
161  string brBookTerm = CCddBookRefToBrString(bookRef);
162  term = BrFcgiBookTermToEutilsTerm(brBookTerm, false);
163  }
164  return term;
165 }
166 
167 string CCddBookRefToBvString(const CCdd_book_ref& bookRef)
168 {
169  string result;
170  string elementid, subelementid, typeString;
171  string bookname = bookRef.GetBookname();
172 
173  if (!bookRef.IsSetElementid() && !bookRef.IsSetCelementid())
174  result = "unexpected book_ref format: neither elementid nor celementid is set";
175 
176  else if (bookRef.IsSetElementid() && bookRef.IsSetCelementid())
177  result = "unexpected book_ref format: both elementid and celementid are set";
178 
179  else if (bookRef.IsSetSubelementid() && bookRef.IsSetCsubelementid())
180  result = "unexpected book_ref format: both subelementid and csubelementid are set";
181 
182  else {
183  elementid = bookRef.IsSetElementid() ? NStr::IntToString(bookRef.GetElementid()) : bookRef.GetCelementid();
184  subelementid = (bookRef.IsSetSubelementid() || bookRef.IsSetCsubelementid()) ?
185  (bookRef.IsSetSubelementid() ? NStr::IntToString(bookRef.GetSubelementid()) : bookRef.GetCsubelementid()) : kEmptyStr;
186 
187  // trim any whitespace on elements/sub-elements
188  NStr::TruncateSpacesInPlace(elementid);
189  NStr::TruncateSpacesInPlace(subelementid);
190 
191  // note: I don't have ownership of the CEnumeratedTypeValues pointer
192  const CEnumeratedTypeValues* allowedElements = CCdd_book_ref::GetTypeInfo_enum_ETextelement();
193  typeString = (allowedElements) ? allowedElements->FindName(bookRef.GetTextelement(), true) : "unassigned";
194 
195  char buf[2048];
196 
197  // Make sure don't have overflow; 15 > length of the longest string in elementStringMap + 1.
198  _ASSERT(bookname.length() + elementid.length() + subelementid.length() + 15 < 2048);
199 
200  if (subelementid.size() > 0)
201  sprintf(buf, "%s.%s.%s#%s", bookname.c_str(), typeString.c_str(), elementid.c_str(), subelementid.c_str());
202  else
203  sprintf(buf, "%s.%s.%s", bookname.c_str(), typeString.c_str(), elementid.c_str());
204  result = string(buf);
205  }
206 
207  return result;
208 }
209 
210 
211 string CCddBookRefToBrString(const CCdd_book_ref& bookRef)
212 {
213  string result;
214  string elementid, subelementid, renderType;
215  string bookname = bookRef.GetBookname();
216 
217  if (!bookRef.IsSetElementid() && !bookRef.IsSetCelementid())
218  result = "unexpected book_ref format: neither elementid nor celementid is set";
219 
220  else if (bookRef.IsSetElementid() && bookRef.IsSetCelementid())
221  result = "unexpected book_ref format: both elementid and celementid are set";
222 
223  else if (bookRef.IsSetSubelementid() && bookRef.IsSetCsubelementid())
224  result = "unexpected book_ref format: both subelementid and csubelementid are set";
225 
226  else {
227 
228  CCdd_book_ref::ETextelement elementType;
229  string part, id;
230 
231  // Numerical element ids need to be prefixed by 'A' in br.fcgi URLs.
232  if (bookRef.IsSetElementid()) {
233  part = "A" + NStr::IntToString(bookRef.GetElementid());
234  } else {
235  part = bookRef.GetCelementid();
236  }
237 
238  if (bookRef.IsSetSubelementid() || bookRef.IsSetCsubelementid()) {
239  // Numerical subelement ids need to be prefixed by 'A' in br.fcgi URLs.
240  if (bookRef.IsSetSubelementid()) {
241  id = "A" + NStr::IntToString(bookRef.GetSubelementid());
242  } else {
243  id = bookRef.GetCsubelementid();
244  }
245  } else {
246  id = kEmptyStr;
247  }
248 
249  // For br.fcgi, 'chapter' and 'section' are treated equivalently.
250  // Expect anything else to be encoded in the 'rendertype' attribute.
251  elementType = bookRef.GetTextelement();
252 
253  if (elementType != CCdd_book_ref::eTextelement_chapter && elementType != CCdd_book_ref::eTextelement_section) {
254  if (elementType == CCdd_book_ref::eTextelement_unassigned || elementType == CCdd_book_ref::eTextelement_other) {
255  result = bookname + "&part=" + part;
256  } else {
257 
258  // note: I don't have ownership of the CEnumeratedTypeValues pointer
259  const CEnumeratedTypeValues* allowedElements = CCdd_book_ref::GetTypeInfo_enum_ETextelement();
260  renderType = kEmptyStr;
261 
262  // For 'eTextelement_figgrp', use 'figure'.
263  if (elementType == CCdd_book_ref::eTextelement_figgrp) {
264  renderType = "figure";
265  // For 'eTextelement_glossary', use 'def-item'.
266  } else if (elementType == CCdd_book_ref::eTextelement_glossary) {
267  renderType = "def-item";
268  } else if (allowedElements) {
269  renderType = allowedElements->FindName(elementType, true);
270  }
271  if (renderType.length() == 0) {
272  renderType = "unassigned";
273  }
274 
275  if (id.length() == 0) {
276  id = part;
277  }
278  result = bookname + "&part=" + part + "&rendertype=" + renderType + "&id=" + id;
279  }
280  } else {
281  result = bookname + "&part=" + part;
282  if (id.size() > 0)
283  result += "#" + id;
284  }
285 
286  }
287 
288  return result;
289 }
290 
291 // The return value is a string used in Portal style URLs based on
292 // .../books/NBK.... The only fields that should be present in
293 // book ref objects are the bookname, text-element type, and a
294 // celementid. Any other field in the spec is ignored.
296 {
297  string result = bookRef.GetBookname();
298  string idStr, renderType;
299 
300  CCdd_book_ref::ETextelement elementType = bookRef.GetTextelement();
301  const CEnumeratedTypeValues* allowedElements = CCdd_book_ref::GetTypeInfo_enum_ETextelement();
302 
303  // 'idStr' should exist for everything except chapters. However,
304  // if we find a chapter with non-empty 'idStr' format it as a
305  // section. Conversely, format sections with no 'idStr' as a chapter.
306  if (bookRef.IsSetCelementid()) {
307  idStr = bookRef.GetCelementid();
308  }
309 
310  if (elementType != CCdd_book_ref::eTextelement_chapter && elementType != CCdd_book_ref::eTextelement_section) {
311 
312  // For 'eTextelement_figgrp', Portal URL requires 'figure'.
313  // For 'eTextelement_glossary', Portal URL requires 'def-item'.
314  renderType = kEmptyStr;
315  if (elementType == CCdd_book_ref::eTextelement_figgrp)
316  renderType = "figure";
317  else if (elementType == CCdd_book_ref::eTextelement_glossary)
318  renderType = "def-item";
319  else if (allowedElements && elementType != CCdd_book_ref::eTextelement_unassigned)
320  renderType = allowedElements->FindName(elementType, true);
321 
322  if (renderType.length() > 0)
323  result += "/" + renderType + "/" + idStr;
324  else if (idStr.length() > 0)
325  result += "/#" + idStr;
326 
327  } else if (idStr.length() > 0) {
328  result += "/#" + idStr;
329  }
330 
331  return result;
332 }
333 
334 bool BrBookURLToCCddBookRef(const string& brBookUrl, CRef< CCdd_book_ref>& bookRef)
335 {
336  bool result = false;
337  string bookname, address, subaddress, typeStr, firstTokenStr;
338  list<string> sharpTokens;
339  CRegexp regexpCommon("book=(.*)&part=(.*)");
340  CRegexp regexpRendertype("&part=(.*)&rendertype=(.*)&id=(.*)");
341 
342  // note: I don't have ownership of the CEnumeratedTypeValues pointer
343  const CEnumeratedTypeValues* allowedElements = CCdd_book_ref::GetTypeInfo_enum_ETextelement();
344 
345  NStr::Split(brBookUrl, "#", sharpTokens, 0);
346  if (sharpTokens.size() == 1 || sharpTokens.size() == 2) {
347  bool haveSubaddr = (sharpTokens.size() == 2);
348 
349  // All URLs have 'book' and 'part' parameters.
350  firstTokenStr = sharpTokens.front();
351  regexpCommon.GetMatch(firstTokenStr, 0, 0, CRegexp::fMatch_default, true);
352  if (regexpCommon.NumFound() == 3) { // i.e., found full pattern + two subpatterns
353 
354  bookname = regexpCommon.GetSub(firstTokenStr, 1);
355 
356  regexpRendertype.GetMatch(firstTokenStr, 0, 0, CRegexp::fMatch_default, true);
357  if (regexpRendertype.NumFound() == 4) { // i.e., expecting anything but a chapter or section
358  address = regexpRendertype.GetSub(firstTokenStr, 1);
359  typeStr = regexpRendertype.GetSub(firstTokenStr, 2);
360 
361  // 'figure' maps to 'eTextelement_figgrp'
362  // 'def-item' maps to 'eTextelement_glossary'
363  if (typeStr == "figure")
364  typeStr = "figgrp";
365  else if (typeStr == "def-item")
366  typeStr = "glossary";
367 
368  if (allowedElements && !allowedElements->IsValidName(typeStr)) {
369  typeStr = kEmptyStr; // problem if we don't have a known type
370  } else {
371  subaddress = regexpRendertype.GetSub(firstTokenStr, 3);
372  }
373  } else { // treat this as a 'section'
374  address = regexpCommon.GetSub(firstTokenStr, 2);
375  typeStr = (allowedElements) ? allowedElements->FindName(CCdd_book_ref::eTextelement_section, true) : "section";
376 
377  // If there's something after the '#', if it's an old-style
378  // URL it could be numeric -> prepend 'A' in that case.
379  if (haveSubaddr) {
380  subaddress = sharpTokens.back();
381  if (NStr::StringToULong(subaddress, NStr::fConvErr_NoThrow) != 0) {
382  subaddress = "A" + subaddress;
383  }
384  }
385  }
386  }
387 
388  if (typeStr.length() > 0) {
389  try {
390  // Throws an error is 'typeStr' is not found.
391  CCdd_book_ref::ETextelement typeEnum = (CCdd_book_ref::ETextelement) allowedElements->FindValue(typeStr);
392  bookRef->SetBookname(bookname);
393  bookRef->SetTextelement(typeEnum);
394  bookRef->SetCelementid(address);
395  if (subaddress.length() > 0) {
396  bookRef->SetCsubelementid(subaddress);
397  }
398  result = true;
399  } catch (...) {
400  result = false;
401  }
402  }
403  }
404 
405  if (!result) {
406  bookRef.Reset();
407  }
408 
409  return result;
410 }
411 
412 bool PortalBookURLToCCddBookRef(const string& portalBookUrl, CRef < CCdd_book_ref >& bookRef)
413 {
414  bool result = false;
415  if (bookRef.Empty()) return result;
416 
417  // remove leading/trailing whitespace from input url
418  string inputStr = NStr::TruncateSpaces(portalBookUrl);
419 
420  string baseStr, nbkCode, idStr;
421  string typeStr = kEmptyStr;
422  CRegexp regexpBase("/books/(NBK.+)");
423  CRegexp regexpNBK("^(NBK[^/]+)");
424  CRegexp regexpRendertype("^NBK[^/]+/(.+)/(.+)");
425 
426  CUrl url(inputStr);
427  CUrlArgs& urlArgs = url.GetArgs();
428  string urlPath = url.GetPath();
429  string urlFrag = url.GetFragment(); // fragment is text after trailing '#'
430 
431  // remove a trailing '/' in the path (e.g., '.../?report=objectonly' form of URLs)
432  if (NStr::EndsWith(urlPath, '/')) {
433  urlPath = urlPath.substr(0, urlPath.length() - 1);
434  }
435 
436  regexpBase.GetMatch(urlPath, 0, 0, CRegexp::fMatch_default, true);
437  if (regexpBase.NumFound() == 2) { // i.e., found full pattern + subpattern
438 
439  baseStr = regexpBase.GetSub(urlPath, 1);
440  nbkCode = regexpNBK.GetMatch(baseStr);
441 
442  regexpRendertype.GetMatch(baseStr, 0, 0, CRegexp::fMatch_default, true);
443  if (regexpRendertype.NumFound() == 3) { // i.e., full pattern + two subpatterns
444  typeStr = regexpRendertype.GetSub(baseStr, 1);
445  idStr = regexpRendertype.GetSub(baseStr, 2);
446  } else if (urlArgs.IsSetValue("rendertype") && urlArgs.IsSetValue("id")) {
447  // If the user somehow pasted a redirected br.fcgi URL.
448  typeStr = urlArgs.GetValue("rendertype");
449  idStr = urlArgs.GetValue("id");
450  } else if (urlFrag.length() > 0) {
451  // A section id appears after the hash character.
452  typeStr = "section";
453  idStr = urlFrag;
454  } else if (urlFrag.length() == 0) {
455  // If there is no URL fragment or obvious type, designate it
456  // a chapter and point to the top of this book page.
457  typeStr = "chapter";
458  idStr = kEmptyStr;
459  }
460  }
461 
462  if (nbkCode.length() > 0) {
463 
464  // 'figure' maps to 'eTextelement_figgrp'
465  // 'def-item' maps to 'eTextelement_glossary'
466  // if have no type at this point, treat as either a section or chapter
467  if (typeStr == "figure")
468  typeStr = "figgrp";
469  else if (typeStr == "def-item")
470  typeStr = "glossary";
471 // else if (typeStr.length() == 0)
472 // typeStr = (idStr.length() > 0) ? "section" : "chapter";
473 
475  const CEnumeratedTypeValues* allowedElements = CCdd_book_ref::GetTypeInfo_enum_ETextelement();
476  if (allowedElements && allowedElements->IsValidName(typeStr)) {
477  // Since 'IsValidName' is true, don't need to catch thrown
478  // error in the case 'typeStr' is not found.
479  typeEnum = (CCdd_book_ref::ETextelement) allowedElements->FindValue(typeStr);
480  } else {
481  // treat invalid typeStr as a 'section' or 'chapter'
483  }
484 
485  bookRef->SetBookname(nbkCode);
486  bookRef->SetTextelement(typeEnum);
487  bookRef->SetCelementid(idStr);
488  result = true;
489  }
490 
491  return result;
492 }
493 
494 
495 
496 END_SCOPE(cd_utils)
const string & FindName(TEnumValueType value, bool allowBadValue) const
Find name of the enum by its numeric value.
Definition: enumerated.cpp:132
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
Definition: regexp.cpp:173
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
Definition: ncbistr.cpp:3081
char * buf
static const char * suffix[]
Definition: pcregrep.c:254
void SetTextelement(TTextelement value)
Assign a value to Textelement data member.
bool
Definition: cgiapp.hpp:496
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3362
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:73
TTextelement GetTextelement(void) const
Get the Textelement member data.
bool IsSetValue(const string &name) const
Check if an argument with the given name exists.
Definition: ncbi_url.hpp:267
bool IsSetCsubelementid(void) const
exact address, if character string Check if a value has been assigned to Csubelementid data member...
Do not throw an exception on error.
Definition: ncbistr.hpp:252
CCdd_book_ref –.
string
Definition: cgiapp.hpp:498
string BrFcgiBookTermToEutilsTerm(const string &brfcgiBookTerm, bool forceOR)
string CCddBookRefToBrString(const CCdd_book_ref &bookRef)
#define kEmptyStr
Definition: ncbistr.hpp:120
bool IsValidName(const CTempString &name) const
Check whether enum with this name is defined.
Definition: enumerated.cpp:126
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5195
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
bool BrBookURLToCCddBookRef(const string &brBookUrl, CRef< CCdd_book_ref > &bookRef)
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:702
CTempString GetSub(CTempString str, size_t idx=0) const
Get pattern/subpattern from previous GetMatch().
Definition: regexp.cpp:159
TElementid GetElementid(void) const
Get the Elementid member data.
string GetPath(void) const
Definition: ncbi_url.hpp:401
int NumFound() const
Get number of patterns + subpatterns.
Definition: regexp.hpp:557
CRegexp –.
Definition: regexp.hpp:69
bool PortalBookURLToCCddBookRef(const string &portalBookUrl, CRef< CCdd_book_ref > &bookRef)
CUrl –.
Definition: ncbi_url.hpp:338
TEnumValueType FindValue(const CTempString &name) const
Find numeric value by the name of the enum.
Definition: enumerated.cpp:110
CUrlArgs::
Definition: ncbi_url.hpp:228
int size
static const NCBI_NS_NCBI::CEnumeratedTypeValues *ENUM_METHOD_NAME() ETextelement(void)
Access to ETextelement's attributes (values, names) as defined in spec.
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.
Definition: ncbistr.cpp:3215
const TCelementid & GetCelementid(void) const
Get the Celementid member data.
bool IsPortalDerivedBookRef(const CCdd_book_ref &bookRef)
string CCddBookRefToBvString(const CCdd_book_ref &bookRef)
CRef –.
Definition: ncbiobj.hpp:616
TSubelementid GetSubelementid(void) const
Get the Subelementid member data.
string GetFragment(void) const
Definition: ncbi_url.hpp:404
const TCsubelementid & GetCsubelementid(void) const
Get the Csubelementid member data.
void SetCsubelementid(const TCsubelementid &value)
Assign a value to Csubelementid data member.
User-defined methods of the data storage class.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3096
else result
Definition: token2.c:20
void SetBookname(const TBookname &value)
Assign a value to Bookname data member.
const string & GetValue(const string &name, bool *is_found=0) const
Get value for the given name.
Definition: ncbi_url.cpp:250
bool IsSetSubelementid(void) const
exact address, used with section Check if a value has been assigned to Subelementid data member...
#define _ASSERT
string CCddBookRefToPortalString(const CCdd_book_ref &bookRef)
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:70
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5544
#define const
Definition: zconf.h:217
bool IsSetCelementid(void) const
address of the text element, if character string Check if a value has been assigned to Celementid dat...
const TBookname & GetBookname(void) const
Get the Bookname member data.
size_type length(void) const
Return the length of the represented array.
Definition: tempstr.hpp:360
bool IsSetElementid(void) const
numerical address of the text-element Check if a value has been assigned to Elementid data member...
static unsigned long StringToULong(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned long.
Definition: ncbistr.cpp:566
string CCddBookRefToEsearchTerm(const CCdd_book_ref &bookRef)
void SetCelementid(const TCelementid &value)
Assign a value to Celementid data member.
const CUrlArgs & GetArgs(void) const
Get const list of arguments.
Definition: ncbi_url.cpp:562
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
string CCddBookRefToString(const CCdd_book_ref &bookRef)
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:756
Modified on Wed Apr 26 17:47:13 2017 by modify_doxy.py rev. 533848