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

Go to the SVN repository for this file.

1 /* $Id: phylo_tree_query_macro_fns.cpp 47479 2023-05-02 13:24:02Z ucko $
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  * Authors: Bob Falk
27  *
28  * File Description:
29  * Implementation for tree query execution
30  */
31 
32 #include <ncbi_pch.hpp>
33 
37 
39 
40 
41 
43 using namespace macro;
44 
45 
46 // Standard javascript events.
47 // This list is taken from: http://help.dottoro.com/ljfvvdnm.php.
49  // Java events
50  "getClass",
51  "JavaPackage",
52  "JavaObject",
53  "JavaArray",
54  "javaClass",
55  "java",
56 
57  // Character input and clipboard events
58  "onbeforecopy",
59  "onbeforecut",
60  "onbeforepaste",
61  "oncopy",
62  "oncut",
63  "oninput",
64  "onkeydown",
65  "onkeypress",
66  "onkeyup",
67  "onpaste",
68  "textInput",
69 
70  // Load, unload and state events
71  "onabort",
72  "onbeforeunload",
73  "onhashchange",
74  "onload",
75  "onoffline",
76  "ononline",
77  "onreadystatechange",
78  "onreadystatechange",
79  "onreadystatechange",
80  "onstop",
81  "onunload",
82 
83  //Form Events
84  "onreset",
85  "onsubmit",
86 
87  // Mouse Events and scrolling
88  "onclick",
89  "oncontextmenu",
90  "ondblclick",
91  "onlosecapture",
92  "onmouseenter",
93  "onmousedown",
94  "onmouseleave",
95  "onmousemove",
96  "onmouseout",
97  "onmouseover",
98  "onmouseup",
99  "onmousewheel",
100  "onscroll",
101 
102  //Move and drag events:
103  "onmovestart",
104  "onmoveend",
105  "onmove",
106  "ondragstart",
107  "ondragleave",
108  "ondragenter",
109  "ondragover",
110  "ondragend",
111  "ondrag",
112  "ondrop",
113 
114  //Resize events:
115  "onresizestart",
116  "onresizeend",
117  "onresize",
118 
119  //Activation and focus events:
120  "onactivate",
121  "onbeforeactivate",
122  "onbeforedeactivate",
123  "onbeforeeditfocus",
124  "onblur",
125  "ondeactivate",
126  "onfocusout",
127  "onfocusin",
128  "onfocus",
129 
130  //Selection events:
131  "oncontrolselect",
132  "onselectionchange",
133  "onselectstart",
134 
135  //Print and help events:
136  "onafterprint",
137  "onbeforeprint",
138  "onhelp",
139 
140  //Error events:
141  "onerrorupdate",
142  "onerror",
143 
144  //DataBound events:
145  "onafterupdate",
146  "onbeforeupdate",
147  "oncellchange",
148  "ondataavailable",
149  "ondatasetchanged",
150  "ondatasetcomplete",
151  "onrowenter",
152  "onrowexit",
153  "onrowsdelete",
154  "onrowsinserted",
155 
156  //Marquee events:
157  "onbounce",
158  "onfinish",
159  "onstart",
160 
161  //Change events:
162  "onchange",
163  "onfilterchange",
164  "onpropertychange",
165 
166  //Search event:
167  "onsearch",
168 
169  //Cross-document communication event:
170  "onmessage",
171 
172  //Additional events:
173  "CheckboxStateChange",
174  "DOMActivate",
175  "DOMAttrModified",
176  "DOMCharacterDataModified",
177  "DOMFocusIn",
178  "DOMFocusOut",
179  "DOMMouseScroll",
180  "DOMNodeInserted",
181  "DOMNodeInsertedIntoDocument",
182  "DOMNodeRemovedFromDocument",
183  "DOMNodeRemoved",
184  "DOMSubtreeModified",
185  "dragdrop",
186  "dragexit",
187  "draggesture",
188  "overflow",
189  "overflowchanged",
190  "RadioStateChange",
191  "underflow"
192 };
193 
194 std::pair<string, string> ITreeMacroFunction::s_JSSwapKeywords[] = {
195  { "<", " less "},
196  { "&lt", " less "},
197  { "&LT", " less "},
198  { "%3c", " less "},
199  { "%3C", " less "},
200  { "&#60", " less "},
201  { "&#x3c", " less "},
202  { "&#x3C", " less "},
203  { "&#x003c", " less "},
204  { "&#x003C", " less "},
205  { "&#x00003c", " less "},
206  { "&#x00003C", " less "},
207  { ">", " greater " },
208  { "&gt", " greater "},
209  { "&GT", " greater "},
210  { "%3e", " greater "},
211  { "%3E", " greater "},
212  { "&#62", " greater "},
213  { "&#x3e", " greater "},
214  { "&#x3E", " greater "},
215  { "&#x003e", " greater "},
216  { "&#x003E", " greater "},
217  { "&#x00003e", " greater "},
218  { "&#x00003E", " greater "}
219 };
220 
221 // JSFilter
222 // Find and replace lists of words in a 'blacklist' from 'str'
223 //
224 // This works with two lists. For the first list we replace each
225 // word in the list with a string of x's of the same length and
226 // a blank on either end so 'onmove' becomes ' xxxx ', 'java' becomes ' xx '
227 // We could just delete the string but this approach shows the caller where
228 // strings were removed And prevents the removal from generating new strings,
229 // e.g. if we remove 'onmove' from 'ononmovemove' we still get 'onmove'.
230 //
231 // The second list is a list of replacement values. We want to maintain
232 // The < and > values but change them to english to prevent valid html
233 // from being injected. I have tried to include all valid encoding variations.
234 //
235 // This is a brute force approach to the problem. There are almost
236 // certainly more efficient approaches for removing a large set of
237 // pre-defined, seldom-occuring strings from an arbitrary string value.
238 string ITreeMacroFunction::JSFilter(const string& str)
239 {
240  string result = str;
241 
242  // Loop through all the keywords to be filtered out, replacing
243  // all instances with a same-length string of the form ' xxx.. '.
244 
245  // Note that the lexical values of some handlers occur as substrings
246  // in other handlers, e.g. ondrag and ondragstart. For a more complete
247  // result, we should put the longer terms ahead of the shorter ones.
248  // If we don't terms like 'ondragstart' will get converted to
249  // ' xxxx start' instead of ' xxxxxxxxx '
250  for (string& keyword : s_JSFilterdKeywords) {
251  size_t pos = NStr::Find(result, keyword, NStr::eNocase);
252  while (pos != NPOS) {
253  string substitution(keyword.size(), 'x');
254  substitution[0] = ' ';
255  substitution[substitution.length()-1] = ' ';
256  result.replace(pos, substitution.length(), substitution);
257 
258  pos = NStr::Find(result, keyword, NStr::eNocase);
259  }
260  }
261 
262  for (std::pair<string,string>& keyword : s_JSSwapKeywords) {
263  NStr::ReplaceInPlace(result, keyword.first, keyword.second);
264  }
265 
266  return result;
267 }
268 
270 {
271  if (m_Args.size() == 1) {
272  string color_str = m_Args[0]->GetString();
273 
274  try {
275  CRgbaColor c(color_str);
276  color_str = "[" + c.ToString(true, true) + "]";
277  }
278  // If color string not valid:
279  catch (const CException&) {
280  NCBI_THROW(CMacroExecException, eWrongArguments,
281  "Cannot convert: " + color_str + " to a color");
282  }
283  m_Node->GetValue().SetFeature(
284  m_Tree->GetFeatureDict(), "$NODE_COLOR", color_str);
285  m_Node->GetValue().InitFeatures(
286  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
287  }
288  else {
289  NCBI_THROW(CMacroExecException, eWrongArguments,
290  "SetColor requires 1 argument but received: " +
291  NStr::NumericToString(m_Args.size()));
292  }
293 }
294 
296 {
297  // Check type - throw exception/ log error?
298  if (m_Args.size() == 1) {
299  Int8 radius;
300  if (m_Args[0]->GetDataType() == QueryValueType::eInt ||
301  m_Args[0]->GetDataType() == QueryValueType::eStringInt ||
302  m_Args[0]->GetDataType() == QueryValueType::eFieldInt) {
303  radius = m_Args[0]->GetInt();
304  }
305  else if (m_Args[0]->GetDataType() == QueryValueType::eFloat ||
306  m_Args[0]->GetDataType() == QueryValueType::eStringFloat ||
307  m_Args[0]->GetDataType() == QueryValueType::eFieldFloat) {
308  radius = Int8(m_Args[0]->GetDouble());
309  }
310  else {
311  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
312 
313  NCBI_THROW(CMacroExecException, eWrongArguments,
314  "SetSize expected an integer but was passed a: " + data_type);
315  }
316 
317  string str_radius = NStr::NumericToString(radius);
318 
319  m_Node->GetValue().SetFeature(
320  m_Tree->GetFeatureDict(), "$NODE_SIZE", str_radius);
321  m_Node->GetValue().InitFeatures(
322  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
323  }
324  else {
325  NCBI_THROW(CMacroExecException, eWrongArguments,
326  "SetSize requires 1 argument but received: " +
327  NStr::NumericToString(m_Args.size()));
328  }
329 }
330 
332 {
333  if (m_Args.size() == 1) {
334  string marker_str = m_Args[0]->GetString();
335 
336  m_Node->GetValue().SetFeature(
337  m_Tree->GetFeatureDict(), "marker", marker_str);
338  m_Node->GetValue().InitFeatures(
339  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
340  }
341  else if (m_Args.size() == 2) {
342  string color_str = m_Args[0]->GetString();
343  Int8 radius = m_Args[1]->GetInt();
344  string radius_str = NStr::NumericToString(radius);
345  string marker_str = color_str + " size=" + radius_str;
346 
347  m_Node->GetValue().SetFeature(
348  m_Tree->GetFeatureDict(), "marker", marker_str);
349  m_Node->GetValue().InitFeatures(
350  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
351  }
352 }
353 
355 {
356  if (m_Args.size() == 1) {
357  string boundary_str = m_Args[0]->GetString();
358 
359  m_Node->GetValue().SetFeature(
360  m_Tree->GetFeatureDict(), "$NODE_BOUNDED", boundary_str);
361  m_Node->GetValue().InitFeatures(
362  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
363  }
364 }
365 
366 
367 
369 {
370  if (m_Args.size() == 2) {
371  string feature_name;
372  if (m_Args[0]->GetDataType() == QueryValueType::eString ||
373  m_Args[0]->GetDataType() == QueryValueType::eFieldString) {
374 
375  feature_name = m_Args[0]->GetString();
376  if (feature_name == "") {
377  NCBI_THROW(CMacroExecException, eWrongArguments,
378  "Blank feature name passed to SetProperty: ");
379  }
380  }
381  else {
382  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
383 
384  NCBI_THROW(CMacroExecException, eWrongArguments,
385  "IsNull expected a string but was passed a: " + data_type);
386  }
387 
388  m_Args[1]->PromoteTo(QueryValueType::eString);
389 
390  // Guard against possible java/javascript attacks (filter any event handlers
391  // and <,> symbols from the text)
392  string filtered_property = ITreeMacroFunction::JSFilter(m_Args[1]->GetString());
393  m_Node->GetValue().SetFeature(
394  m_Tree->GetFeatureDict(), feature_name, filtered_property);
395  m_Node->GetValue().InitFeatures(
396  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
397  }
398  else {
399  NCBI_THROW(CMacroExecException, eWrongArguments,
400  "SetProperty requires 2 arguments but received: " +
401  NStr::NumericToString(m_Args.size()));
402  }
403 }
404 
406 {
407 public:
408  CVisitorAccumulateProperty(const string& feature_name, bool include_node, CPhyloTree::TTreeIdx main_node_idx)
409  : m_FeatName(feature_name)
410  , m_IncludeNode(include_node)
411  , m_SumInt(0)
412  , m_SumDbl(0.0)
413  , m_SumIsInteger(true)
414  , m_MainNode(main_node_idx) {}
415 
417  {
418  if ((delta == 0 || delta == 1) && (m_IncludeNode || node_idx != m_MainNode)) {
419  CPhyloTreeNode& node = tree[node_idx];
420 
421  string feature_value;
422  auto feat_list = node.GetValue().GetBioTreeFeatureList();
423  bool has_value = feat_list.GetFeatureValue(tree.GetFeatureDict().GetId(m_FeatName), feature_value);
424  if (has_value && !feature_value.empty()) {
425  try {
427  if (errno == 0) {
428  m_SumInt += value;
429  }
430  else {
431  double value = NStr::StringToDouble(feature_value);
432  m_SumIsInteger = false;
433  m_SumDbl += value;
434  }
435  }
436  catch (const CException& e) {
437  NCBI_THROW(CMacroExecException, eInvalidData,
438  "Summation of existing property values failed: " + e.GetMsg());
439  }
440  }
441  }
442 
443  return eTreeTraverse;
444  }
445 
446  bool IsSumInteger() const { return m_SumIsInteger; }
447  Int8 GetInteger() const { return m_SumInt; }
448  double GetDouble() const { return m_SumDbl; }
449 private:
450  string m_FeatName;
452 
454  double m_SumDbl;
457 
458 };
459 
461 {
462  if (m_Args.size() != 2) {
463  NCBI_THROW(CMacroExecException, eWrongArguments,
464  "SubtreeSum requires 2 arguments but received: " +
465  NStr::NumericToString(m_Args.size()));
466  }
467 
468  if (m_Args[0]->GetDataType() != QueryValueType::eString &&
469  m_Args[0]->GetDataType() != QueryValueType::eFieldString) {
470 
471  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
472  NCBI_THROW(CMacroExecException, eWrongArguments,
473  "SubtreeSum expected a string but was passed a: " + data_type);
474  }
475 
476  const string& existing_feature = m_Args[0]->GetString();
477 
478  if (existing_feature.empty()) {
479  NCBI_THROW(CMacroExecException, eWrongArguments,
480  "Blank existing feature name passed to SubtreeSum: ");
481  }
482 
483  if (!m_Tree->GetFeatureDict().HasFeature(existing_feature)) {
484  NCBI_THROW(CMacroExecException, eWrongArguments,
485  existing_feature + " is not a property of the tree nodes.");
486  }
487 
488  bool include_node = false;
489  if (m_Args[1]->GetDataType() == QueryValueType::eBool ||
490  m_Args[1]->GetDataType() == QueryValueType::eFieldBool) {
491 
492  include_node = m_Args[1]->GetBool();
493  }
494  else {
495  string data_type = QueryValueType::GetTypeAsString(m_Args[1]->GetDataType());
496  NCBI_THROW(CMacroExecException, eWrongArguments,
497  "SubtreeSum expected a boolean but was passed a: " + data_type);
498  }
499 
500  auto current_node_idx = m_Tree->FindNodeById(m_Node->GetValue().GetId());
501  CVisitorAccumulateProperty visitor = TreeDepthFirst(*m_Tree, current_node_idx,
502  CVisitorAccumulateProperty(existing_feature, include_node, current_node_idx));
503 
504  string new_value;
505  if (visitor.IsSumInteger()) {
506  new_value = NStr::Int8ToString(visitor.GetInteger());
507  }
508  else {
509  double sum_double = visitor.GetDouble();
510  sum_double += static_cast<double>(visitor.GetInteger());
511  new_value = NStr::DoubleToString(sum_double);
512  }
513 
514  m_Result->SetString(new_value);
515 }
516 
518 {
519  // Only collapse if node has children and they are hidden
520  if (m_Node->NumChildren() > 0 &&
521  m_Node->GetValue().GetDisplayChildren() == CPhyloNodeData::eShowChildren) {
522  m_Node->GetValue().SetFeature(m_Tree->GetFeatureDict(),
523  "$NODE_COLLAPSED", "1");
524  m_Node->GetValue().InitFeatures(
525  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
526  }
527 }
528 
530 {
531  // Don't expand it (update $NODE_COLLAPSED property) unless the node is
532  // currently collapsed
533  if (m_Node->GetValue().GetDisplayChildren() == CPhyloNodeData::eHideChildren) {
534  m_Node->GetValue().SetFeature(m_Tree->GetFeatureDict(),
535  "$NODE_COLLAPSED", "0");
536  m_Node->GetValue().InitFeatures(
537  m_Tree->GetFeatureDict(), m_Tree->GetColorTable());
538  }
539 }
540 
542 {
543  CPhyloSelectionSetMgr& sel_sets = m_Tree->GetSelectionSets();
544 
545  if (m_Args.size() != 1 && m_Args.size() != 2) {
546  NCBI_THROW(CMacroExecException, eWrongArguments,
547  "AddToSelectionSet requires 1 argument (name) or 2 (name and color) arguments but received: " +
548  NStr::NumericToString(m_Args.size()));
549  }
550 
551  string set_name;
552  if (m_Args[0]->GetDataType() != QueryValueType::eString &&
553  m_Args[0]->GetDataType() != QueryValueType::eFieldString) {
554  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
555 
556  NCBI_THROW(CMacroExecException, eWrongArguments,
557  "AddToSelectionSet expected first parameter to be a string but was passed a: " + data_type);
558  }
559  else {
560  set_name = m_Args[0]->GetString();
561  if (set_name == "") {
562  NCBI_THROW(CMacroExecException, eWrongArguments,
563  "Blank set name passed to AddToSelectionSet: ");
564  }
565  }
566 
567  if (m_Args.size() == 2) {
568  if (m_Args[1]->GetDataType() != QueryValueType::eString &&
569  m_Args[1]->GetDataType() != QueryValueType::eFieldString) {
570  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
571 
572  NCBI_THROW(CMacroExecException, eWrongArguments,
573  "AddToSelectionSet expected second parameter to be a color string but was passed a: " + data_type);
574  }
575 
576  CRgbaColor c;
577 
578  try {
579  c.FromString(m_Args[1]->GetString());
580  }
581  // If color string not valid:
582  catch (const CException&) {
583  NCBI_THROW(CMacroExecException, eWrongArguments,
584  "Cannot convert: " + m_Args[1]->GetString() + " to a color");
585  }
586 
587  CPhyloSelectionSet& s = sel_sets.AddSet(set_name, c);
588  x_AddSetInfo(s);
589  }
590  else {
591  CPhyloSelectionSet& s = sel_sets.AddSet(set_name);
592  x_AddSetInfo(s);
593  }
594 }
595 
597 {
598  s.GetSelectionSet().push_back(m_Node->GetValue().GetId());
599  s.SetSelected(true);
600 }
601 
603 {
604  if (!m_Args.empty()) {
605  return;
606  }
607 
608  auto parent_idx = (m_Node->HasParent()) ? m_Node->GetParent() : CPhyloTree::Null();
609  if (parent_idx == CPhyloTree::Null()) {
610  // the root node can not be removed
611  return;
612  }
613 
614  for (auto&& it = m_Node->SubNodeBegin(); it != m_Node->SubNodeEnd(); it++) {
615  m_Tree->AddChild(parent_idx, *it);
616  }
617 
618  auto current_node_idx = m_Tree->FindNodeById(m_Node->GetValue().GetId());
619  m_Node->ClearConnections();
620  m_Tree->RemoveChild(parent_idx, current_node_idx);
621  m_Node->GetValue().SetId(CPhyloNodeData::TID(-1));
622 }
623 
625 {
626  bool is_leaf = m_Node->IsLeaf();
627  m_Result->SetBool(is_leaf);
628  m_Result->SetValue(is_leaf);
629  m_Result->SetDataType(QueryValueType::eBool);
630 }
631 
633 {
634  m_Result->SetInt(m_Node->NumChildren());
635  m_Result->SetDataType(QueryValueType::eInt);
636 }
637 
639 {
640  m_Result->SetInt(m_Result->GetBranchDepth());
641  m_Result->SetDataType(QueryValueType::eInt);
642 }
643 
645 {
646  m_Result->SetInt(m_Result->GetMaxChildBranchDepth());
647  m_Result->SetDataType(QueryValueType::eInt);
648 }
649 
651 {
652  if (m_Args.size() == 1) {
653  string feature_name;
654  bool is_null = true;
655 
656  if (m_Args[0]->GetDataType() == QueryValueType::eString ||
657  m_Args[0]->GetDataType() == QueryValueType::eFieldString) {
658 
659  feature_name = m_Args[0]->GetString();
660  if (m_Tree->GetFeatureDict().HasFeature(feature_name)) {
661  string feat_value;
662  is_null = !m_Node->GetValue().GetBioTreeFeatureList().GetFeatureValue(
663  m_Tree->GetFeatureDict().GetId(feature_name), feat_value);
664  }
665  }
666  else {
667  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
668 
669  NCBI_THROW(CMacroExecException, eWrongArguments,
670  "IsNull expected a string but was passed a: " + data_type);
671  }
672 
673  m_Result->SetBool(is_null);
674  m_Result->SetValue(is_null);
675  m_Result->SetDataType(QueryValueType::eBool);
676  }
677  else {
678  NCBI_THROW(CMacroExecException, eWrongArguments,
679  "IsNull requires 1 argument but received: " +
680  NStr::NumericToString(m_Args.size()));
681  }
682 }
683 
685 {
686  if (m_Args.size() == 1 || m_Args.size() == 2) {
687  if (m_Args[0]->GetDataType() == QueryValueType::eString ||
688  m_Args[0]->GetDataType() == QueryValueType::eFieldString) {
689 
690  string format = "";
691  if (m_Args.size() == 2) {
692  if (m_Args[1]->GetDataType() == QueryValueType::eString ||
693  m_Args[1]->GetDataType() == QueryValueType::eFieldString) {
694  format = m_Args[1]->GetString();
695  }
696  else {
697  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
698  NCBI_THROW(CMacroExecException, eWrongArguments,
699  "Date expected a date format string but was passed a: " + data_type);
700  }
701  }
702 
703  CTimeFormat tf;
704  if (format != "")
706  else
708 
709  string str_date = m_Args[0]->GetString();
710  // If the string is blank we have essentially a null value. generally we would
711  // want the full query to evaluate to false, but that is up to the user who needs
712  // to check with IsLeaf or IsNull or not field="".
713  if (str_date == "") {
714  m_Result->SetInt(0);
715  m_Result->SetDataType(QueryValueType::eInt);
716  }
717  else {
718  // Get time in seconds since midnight (00:00:00), January 1, 1970 UTC
719  // This may be a 64 bit type.
720  CTime date(str_date, tf);
721  time_t t = date.GetTimeT();
722 
723  // 32 bit types will work until 2038. If it is 2037 and you are reading this,
724  // please make the necessary changes.
725  m_Result->SetInt((int)t);
726  m_Result->SetDataType(QueryValueType::eInt);
727  }
728  }
729  else {
730  string data_type = QueryValueType::GetTypeAsString(m_Args[0]->GetDataType());
731  NCBI_THROW(CMacroExecException, eWrongArguments,
732  "Date expected a date string but was passed a: " + data_type);
733  }
734  }
735  else {
736  NCBI_THROW(CMacroExecException, eWrongArguments,
737  "Date requires 1 or 2 arguments but received: " +
738  NStr::NumericToString(m_Args.size()));
739  }
740 }
741 
742 
#define true
Definition: bool.h:35
class CMacroExecException
Definition: macro_ex.hpp:196
CBioTreeFeatureList & GetBioTreeFeatureList()
objects::CNode::TId TID
CPhyloSelectionSet & AddSet(const string &set_name)
Add the new set set_name and return it. If it already exists, just return it.
vector< objects::CNode::TId > & GetSelectionSet()
Tree subclass also has functions and data needed for rendering and selection.
Definition: phylo_tree.hpp:52
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CTimeFormat –.
Definition: ncbitime.hpp:131
CTime –.
Definition: ncbitime.hpp:296
TData & GetValue()
Return the value object for the node.
Definition: tree_model.hpp:159
static TTreeIdx Null()
Return the index value that represents a NULL node.
Definition: tree_model.hpp:678
ETreeTraverseCode operator()(CPhyloTree &tree, CPhyloTree::TTreeIdx node_idx, int delta)
CVisitorAccumulateProperty(const string &feature_name, bool include_node, CPhyloTree::TTreeIdx main_node_idx)
static string JSFilter(const string &str)
Filter out java/javascript keywords that could possibly be used in xss attacks, particularly event ha...
static pair< string, string > s_JSSwapKeywords[]
char value[7]
Definition: config.c:431
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
string ToString(bool printAlpha=true, bool uchars=true) const
Return a string representation of the current color.
Definition: rgba_color.cpp:309
void FromString(const string &str)
Assign color values encoded in a string.
Definition: rgba_color.cpp:363
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
Definition: ncbistr.hpp:5158
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
Definition: ncbistr.hpp:5186
static Int8 StringToInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Int8.
Definition: ncbistr.cpp:793
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
Definition: ncbistr.cpp:1387
#define NPOS
Definition: ncbistr.hpp:133
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2887
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static string & ReplaceInPlace(string &src, const string &search, const string &replace, 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:3401
@ fConvErr_NoThrow
Do not throw an exception on error.
Definition: ncbistr.hpp:285
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
void SetFormat(const char *fmt, TFlags flags=fDefault)
Set the current time format.
Definition: ncbitime.hpp:2231
time_t GetTimeT(void) const
Get time in time_t format.
Definition: ncbitime.cpp:1395
@ fMatch_Weak
Combination of both modes above.
Definition: ncbitime.hpp:165
@ fFormat_Simple
Use single characters as format symbols.
Definition: ncbitime.hpp:144
ETreeTraverseCode
Tree traverse code returned by the traverse predicate function.
Definition: ncbi_tree.hpp:51
const string & GetFeatureValue(TBioTreeFeatureId id) const
Get feature value by id.
Definition: bio_tree.cpp:69
@ eTreeTraverse
Keep traversal.
Definition: ncbi_tree.hpp:52
Macro exceptions.
string GetTypeAsString(EBaseType et)
EIPRangeType t
Definition: ncbi_localip.c:101
static Format format
Definition: njn_ioutil.cpp:53
Int4 delta(size_t dimension_, const Int4 *score_)
static const char * str(char *buf, int n)
Definition: stats.c:84
else result
Definition: token2.c:20
Fun TreeDepthFirst(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun func)
Depth-first tree traversal algorithm.
Definition: tree_model.hpp:355
Modified on Fri Dec 01 04:46:26 2023 by modify_doxy.py rev. 669887