shift polytope for PIP if variables range over negative and positive values
[barvinok.git] / debug.cpp
blobbc5df0d6a8570cbd0de8526e217586d559538901
1 #include "debug.h"
2 #include <fstream>
3 #include <cctype>
4 #include <iostream>
5 #include <deque>
6 #if 0
7 #include "polyast.h"
8 #include "constraint.h"
9 #endif
11 using namespace std;
13 #define MAX_LINE_LENGTH 1024
15 DynamicDebug::DynamicDebug(ifstream& DebugConfigStream)
17 char line[MAX_LINE_LENGTH];
18 while (DebugConfigStream.getline(line, MAX_LINE_LENGTH)) {
19 // parse line. Possible formats:
20 // DEBUG_PARAMETER
21 // DEBUG_PARAMETER level
22 string word;
23 long level;
24 int i;
25 for(i=0; !isspace(line[i]) && line[i]!=0; i++)
26 word += line[i];
27 while (isspace(line[i] && line[i]!=0)) i++;
28 if (line[i]!=0) {
29 // start parsing level;
30 char *p;
31 level = strtol(line+i, &p, 10);
32 while(isspace(*p) && *p!=0) p++;
33 if (*p!=0) {
34 cerr<<"Error while parsing Debug Parameters!!\n"
35 <<"for parameter '"<<word<<"', "
36 <<" found level "<<level<<", but level was "
37 <<"not last non-white on line."<<endl;
39 } else {
40 level=1;
42 add(word, level);
46 inline DynamicDebug::DynamicDebug(const char* DebugConfigFile)
48 ifstream DebugConfigStream(DebugConfigFile);
49 char line[MAX_LINE_LENGTH];
50 while (DebugConfigStream.getline(line, MAX_LINE_LENGTH)) {
51 // parse line. Possible formats:
52 // DEBUG_PARAMETER
53 // DEBUG_PARAMETER level
54 string word;
55 long level;
56 int i;
57 for(i=0; !isspace(line[i]) && line[i]!=0; i++)
58 word += line[i];
59 while (isspace(line[i] && line[i]!=0)) i++;
60 if (line[i]!=0) {
61 // start parsing level;
62 char *p;
63 level = strtol(line+i, &p, 10);
64 while(isspace(*p) && *p!=0) p++;
65 if (*p!=0) {
66 cerr<<"Error while parsing Debug Parameters!!\n"
67 <<"for parameter '"<<word<<"', "
68 <<" found level "<<level<<", but level was "
69 <<"not last non-white on line."<<endl;
71 } else {
72 level=1;
74 add(word, level);
78 //ifstream DEBUG_CONFIGURATION_FILE("DEBUG_POLYAST");
79 DynamicDebug DebugBlackboard("DEBUG_POLYAST");
81 deque<string> split_underscore(const string& s)
83 deque<string> result;
84 const char* word_begin = s.c_str();
85 const char* c=s.c_str();
86 for(; (*c)!=0; c++) {
87 if ((*c)=='_') {
88 result.push_back(string(word_begin, c-word_begin));
89 word_begin = c+1;
92 if (word_begin<c)
93 result.push_back(string(word_begin, c-word_begin));
94 cout<<"in split_underscore("<<s<<"): returned (";
95 for (unsigned i=0;i<result.size();i++)
96 cout<<((i!=0)?",":"")<<result[i];
97 cout<<")"<<endl;
98 return result;