CASM  1.1.0
A Clusters Approach to Statistical Mechanics
RoadLogEvent.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (c) 2008-2015 C.B. Barber. All rights reserved.
4 ** $Id: //main/2015/qhull/src/libqhullcpp/RoadLogEvent.cpp#1 $$Change: 1981 $
5 ** $Date: 2015/09/28 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #
10 
11 #include "RoadError.h"
12 
13 #include <string>
14 #include <sstream>
15 #include <iostream>
16 
17 using std::cout;
18 using std::endl;
19 using std::ostringstream;
20 using std::string;
21 
22 #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
23 #endif
24 
25 namespace orgQhull {
26 
27 #
28 string RoadLogEvent::
29 toString(const char *tag, int code) const
30 {
31  ostringstream os;
32  if(tag && code){
33  os << tag << code;
34  if(format_string){
35  os << " ";
36  }
37  }
38  if(!format_string){
39  return os.str();
40  }
41  const char *s= format_string;
42  int dCount= 0; // Count of %d
43  int fCount= 0; // Count of %f
44  char extraCode= '\0';
45  while(*s){
46  if(*s!='%'){
47  os << *s++;
48  }else{
49  char c= *++s;
50  s++;
51  switch(c){
52  case 'd':
53  if(++dCount>2){
54  os << " ERROR_three_%d_in_format ";
55  }else if(dCount==2){
56  os << int_2;
57  }else{
58  os << int_1;
59  }
60  break;
61  case 'e':
62  if(firstExtraCode(os, c, &extraCode)){
63  os << double_1;
64  }
65  break;
66  case 'f':
67  if(++fCount>1){
68  os << " ERROR_two_%f_in_format ";
69  }else{
70  os << float_1;
71  }
72  break;
73  case 'i':
74  if(firstExtraCode(os, c, &extraCode)){
75  os << int64_1;
76  }
77  break;
78  case 's':
79  if(firstExtraCode(os, c, &extraCode)){
80  os << cstr_1;
81  }
82  break;
83  case 'u':
84  if(firstExtraCode(os, c, &extraCode)){
85  os << "0x" << std::hex << int64_1 << std::dec;
86  }
87  break;
88  case 'x':
89  if(firstExtraCode(os, c, &extraCode)){
90  os << void_1;
91  }
92  break;
93  case '%':
94  os << c;
95  break;
96  default:
97  os << " ERROR_%" << c << "_not_defined_in_format";
98  break;
99  }
100  }
101  }
102  if(s[-1]!='\n'){
103  os << endl;
104  }
105  return os.str();
106 }//toString
107 
108 #
109 
111 bool RoadLogEvent::
112 firstExtraCode(std::ostream &os, char c, char *extraCode){
113  if(*extraCode){
114  os << " ERROR_%" << *extraCode << "_and_%" << c << "_in_format ";
115  return false;
116  }
117  *extraCode= c;
118  return true;
119 }//firstExtraCode
120 
121 }//namespace orgQhull
122 
std::set< std::string > & s
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:20