source: ThirdParty/mpqc_open/src/lib/util/keyval/ipv2_print.cc@ 4464ef

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 4464ef was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 4.1 KB
RevLine 
[0b990d]1//
2// ipv2_print.cc
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#include <iostream>
29#include <util/misc/formio.h>
30#include <util/keyval/ipv2.h>
31
32using namespace std;
33using namespace sc;
34
35void
36IPV2::print_keyword(ostream&fp,ip_keyword_tree_t*st)
37{
38 if (st) {
39 if (st->up) print_keyword(fp,st->up);
40 fp << st->keyword << ":";
41 }
42 }
43
44/* This prints out a keyword tree, tree. If tree is NULL then ip_tree
45 * is printed out. */
46void
47IPV2::print_tree(ostream&fp,ip_keyword_tree_t*tree)
48{
49 if (!tree) tree = ip_tree;
50 if (!tree) return;
51
52 print_tree_(fp,tree);
53 }
54
55
56/* This prints out a keyword tree, tree. If tree is NULL then ip_tree
57 * is printed out. */
58void
59IPV2::print_tree_(ostream&fp,ip_keyword_tree_t*tree)
60{
61 ip_keyword_tree_t *I;
62
63 I=tree;
64 do {
65 //if (I->value && I->down) {
66 // warn("print_tree: tree has both value and subtrees - can't print");
67 // warn("keyword is %s, value is %s, subtree key is %s\n",
68 // I->keyword,I->value,I->down->keyword);
69 // }
70
71 if (!I->keyword) {
72 warn("print_tree: tree has no keyword - impossible");
73 }
74
75 fp << indent;
76 if (ip_special_characters(I->keyword)) {
77 fp << "\"" << I->keyword << "\"" << endl;
78 }
79 else {
80 fp << I->keyword << endl;
81 }
82
83 if (I->classname) {
84 fp << "<" << I->keyword << ">" << endl;
85 }
86
87 if (!(I->value || I->down || I->variable)) {
88 fp << ": (" << endl;
89 }
90
91 if (I->variable) {
92 fp << " = $" << I->variable << endl;
93 }
94 if (I->truename) {
95 fp << "\"" << I->truename << "\"";
96 }
97
98 if (I->value) {
99 if (I->down) fp << " (= " << I->value << ")";
100 else fp << " = " << I->value << endl;
101 }
102 if (I->down) {
103 fp << ": (" << endl;
104 fp << incindent;
105 print_tree_(fp,I->down);
106 fp << decindent;
107 fp << indent << ")" << endl;
108 }
109
110 } while ((I = I->across) != tree);
111
112 }
113
114/* This prints out a keyword tree, tree. If tree is NULL then ip_tree
115 * is printed out. */
116void
117IPV2::print_unseen(ostream&fp,ip_keyword_tree_t*I)
118{
119 if (!I) I = ip_tree;
120 if (!I) return;
121 ip_keyword_tree_t *start = I;
122 do {
123 if (!I->seen) {
124 fp << indent;
125 print_keyword(fp,I->up);
126 fp << I->keyword << endl;
127 }
128 else if (I->down) {
129 print_unseen(fp,I->down);
130 }
131 } while ((I = I->across) != start);
132}
133
134/* This prints out a keyword tree, tree. If tree is NULL then ip_tree
135 * is printed out. */
136int
137IPV2::have_unseen(ip_keyword_tree_t*I)
138{
139 if (!I) I = ip_tree;
140 if (!I) return 0;
141 ip_keyword_tree_t *start = I;
142 do {
143 if (!I->seen) {
144 return 1;
145 }
146 else if (I->down) {
147 if (have_unseen(I->down)) return 1;
148 }
149 } while ((I = I->across) != start);
150 return 0;
151}
152
153int
154IPV2::ip_special_characters(char*keyword)
155{
156 char *ch=keyword;
157
158 if (!keyword) return 0;
159 while (*ch) {
160 if (!( (*ch >= 'a' && *ch <= 'z')
161 ||(*ch >= 'A' && *ch <= 'Z')
162 ||(*ch >= '0' && *ch <= '9')
163 ||(*ch == '<')
164 ||(*ch == '>')
165 ||(*ch == '+')
166 ||(*ch == '-')
167 ||(*ch == '.')
168 ||(*ch == '_'))) return 1;
169
170 ch++;
171 }
172
173 return 0;
174 }
Note: See TracBrowser for help on using the repository browser.