diff --git a/Makefile b/Makefile
index 179f0af76e5091c5a843a9289dd95f3bcaa8fd9c..c1cc05f6ecdcd1d81102985d61ef730a2a1d137c 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ DIR_TRACE = trace/src
all:
# @(cd $(DIR_TRACE) && make)
# @(cd $(DIR_PARSER) && make)
- @(cd $(DIR_INTERFACE) && make)
+ make -C $(DIR_INTERFACE)
@echo " "
@echo "Compilation completed! File created in 'bin' folder."
@echo " "
@@ -35,9 +35,11 @@ doc:
debugs:
- @(cd $(DIR_INTERFACE) && make debugs)
+ make debugs -C $(DIR_INTERFACE)
+# @(cd $(DIR_INTERFACE) && make debugs)
# @(cd $(DIR_TRACE) && make)
- @(cd $(DIR_PARSER) && make debug)
+ make debug -C $(DIR_PARSER)
+# @(cd $(DIR_PARSER) && make debug)
@echo " "
@echo "Compilation completed! (debug)"
@echo " "
@@ -52,8 +54,9 @@ clean:
# Must be called with option -i, otherwise an error occured in the first instructions, the followings won't be executed.
wash:
- @(cd $(DIR_TRACE) && make clean)
- @(cd $(DIR_INTERFACE) && make clean)
- @(cd $(DIR_PARSER) && make clean)
+ make clean -C $(DIR_INTERFACE)
+ make clean -C $(DIR_TRACE)
+ make clean -C $(DIR_PARSER)
+
cd bin && $(RM) *
diff --git a/interface/Makefile b/interface/Makefile
index 8732cf90c98a78360a7d3f61eea44c2c7517d1bc..56d81a4762ff148f44425b83bfc59360cf8f89b2 100644
--- a/interface/Makefile
+++ b/interface/Makefile
@@ -65,7 +65,7 @@ clean:
# Must be called with option -i, otherwise an error occured in the first instructions, the followings won't be executed.
wash:
- cd ./src && rm *~ *.o Makefile qrc_vite.cpp core
- cd ./tests && rm *~ *.o Makefile core
- cd ./bin && rm *.o
- cd ./debug && rm *
+ cd ./src && $(RM) *~ *.o Makefile qrc_vite.cpp core
+ cd ./tests && $(RM) *~ *.o Makefile core
+ cd ./bin && $(RM) *.o
+ cd ./debug && $(RM) *
diff --git a/interface/src/render_svg.cpp b/interface/src/render_svg.cpp
index e3e328826df86e3d3d55fa639ca6c0331c627a54..750d57bbaac66ec988542d14a92c6fa366eebb0b 100644
--- a/interface/src/render_svg.cpp
+++ b/interface/src/render_svg.cpp
@@ -1,76 +1,68 @@
#include "render_svg.hpp"
+using namespace std;
- void Svg::rectangle()
- {
- _buffer << "";
- afficher();
- }
+void Svg::rectangle(){
+ _buffer << "";
+ afficher();
+}
- void Svg::afficher()
- {
+void Svg::afficher(){
- if (_buffer.str().size()>BUFFER_SIZE){
- svg_file.write(_buffer.str().c_str(), _buffer.str().size());
+ if (_buffer.str().size()>BUFFER_SIZE){
+ _svg_file.write(_buffer.str().c_str(), _buffer.str().size());
_buffer.flush();
- }
+ }
- }
+}
- void Svg::init(char * path)
- {
+void Svg::init(char *path){
- svg_file.open(path , ofstream::out | ofstream::trunc);
+ _svg_file.open(path , ofstream::out | ofstream::trunc);
- if (svg_file.is_open()==false){
+ if (_svg_file.is_open()==false){
std::cerr<<"unable to open file";
- }
- _buffer << "\n\n";
- svg_file.write(_buffer.str().c_str(), _buffer.str().size());
- _buffer.flush();
- svg_file.close();
- }
- void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h)
- {
-
-
- _r=0xff;
- _g=0x44;
- _b=0xcc;
- _w=(unsigned long)w;
- _h=(unsigned long)h;
- _x=(unsigned long)x;
- _y=(unsigned long)y;
- rectangle();
-
- }
- void Svg::draw_state(const Element_pos start , const Element_pos end, const Element_count level, const Element_col r, const Element_col g, const Element_col b)
- {
-
-
- _r=(unsigned char)r;
- _g=(unsigned char)g;
- _b=(unsigned char)b;
- _w=(unsigned long)(end-start);
- _h=(unsigned long)LEVEL - 10;
- _x=(unsigned long)start;
- _y=(unsigned long)level*LEVEL;
- rectangle();
-
-
-
- }
+ }
+ _buffer << "\n\n";
+ _svg_file.write(_buffer.str().c_str(), _buffer.str().size());
+ _buffer.flush();
+ _svg_file.close();
+}
+void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){
+
+
+ _r=0xff;
+ _g=0x44;
+ _b=0xcc;
+ _w=(unsigned long)w;
+ _h=(unsigned long)h;
+ _x=(unsigned long)x;
+ _y=(unsigned long)y;
+ rectangle();
+}
+
+void Svg::draw_state(const Element_pos start , const Element_pos end, const Element_count level, const Element_col r, const Element_col g, const Element_col b){
+
+ _r=(unsigned char)r;
+ _g=(unsigned char)g;
+ _b=(unsigned char)b;
+ _w=(unsigned long)(end-start);
+ _h=(unsigned long)LEVEL - 10;
+ _x=(unsigned long)start;
+ _y=(unsigned long)level*LEVEL;
+ rectangle();
+
+}
diff --git a/interface/src/render_svg.hpp b/interface/src/render_svg.hpp
index 2af8a31ee679ddb112399d3bcb761c24d93acfa9..0ba3b67e0c563be002d639e6558e4bfc0a76482e 100644
--- a/interface/src/render_svg.hpp
+++ b/interface/src/render_svg.hpp
@@ -1,4 +1,4 @@
-#ifndef RENDER_SGV
+#ifndef RENDER_SVG
#define RENDER_SVG
#include
#include
@@ -6,8 +6,6 @@
#include
#define BUFFER_SIZE 2048
#define LEVEL 110
-using namespace std;
-
typedef unsigned long Element_count ;
typedef double Element_pos;
@@ -17,44 +15,44 @@ typedef unsigned int Element_col;
class Svg{
- private:
+private:
ostringstream _buffer;
- ofstream svg_file;
+ ofstream _svg_file;
unsigned int _r,_g,_b;
unsigned long _x,_y,_w,_h;
void afficher();
void rectangle();
- public:
- /*!
+public:
+ /*!
* \brief SVG header buiding
*/
- void init(char *path);
+ void init(char *path);
- /*!
+ /*!
* \brief SVG bottom file buiding
*/
- void end();
+ void end();
- /*!
+ /*!
* \brief Draw a container according to the parameters
* \param x the x position of the container
* \param y the y position of the container
* \param w the width of the container
* \param h the height of the container
*/
- void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) ;
-
- /*!
- * \brief Draw a state of the trace.
- * \param r the red color rate of the state.
- * \param g the green color rate of the state.
- * \param b the blue color rate of the state.
- * \param start the beginning time of the state.
- * \param end the ending time of the state.
- * \param level refer to the container which state belongs to.
- */
- void draw_state(const Element_pos start , const Element_pos end, const Element_count level, const Element_col r, const Element_col g, const Element_col b) ;
- };
-
-#endif// RENDER_SGV
+ void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) ;
+
+ /*!
+ * \brief Draw a state of the trace.
+ * \param r the red color rate of the state.
+ * \param g the green color rate of the state.
+ * \param b the blue color rate of the state.
+ * \param start the beginning time of the state.
+ * \param end the ending time of the state.
+ * \param level refer to the container which state belongs to.
+ */
+ void draw_state(const Element_pos start , const Element_pos end, const Element_count level, const Element_col r, const Element_col g, const Element_col b) ;
+};
+
+#endif // RENDER_SVG
diff --git a/main.cpp b/main.cpp
index ce41fd1059bc92bf024a92475fa40c86797895b1..c3d50fdb3f05cb0ea05eb0173e51ff7e25665cbf 100644
--- a/main.cpp
+++ b/main.cpp
@@ -13,8 +13,7 @@
/*!
*\brief The main function of ViTE.
*/
- int main(int argc, char **argv)
- {
+ int main(int argc, char **argv) {
glutInit(&argc, argv);
Interface_console console(argc, argv);
diff --git a/parser/src/TokenSource.cpp b/parser/src/TokenSource.cpp
index eda4b787773087447b6508eece3e41682d85e73c..62d38efa94b3bb3b7b10a3c906e45892a2ae8fbe 100644
--- a/parser/src/TokenSource.cpp
+++ b/parser/src/TokenSource.cpp
@@ -1,5 +1,204 @@
-#ifndef MAPPINGDENIED
-#include "TokenSource_mmap.cpp"
+#include "TokenSource.hpp"
+
+using namespace std;
+
+TokenSource::TokenSource(){
+ //no file are opened
+ //you must use open later
+ _eof = true;
+}
+
+
+TokenSource::TokenSource(const char *filename){
+ sopen(filename);
+}
+
+TokenSource::~TokenSource(){
+#ifdef WIN32
+ _file.close();
#else
-#include "TokenSource_fstream.hpp"
+ if (munmap(_buffer, _filesize) == -1){
+ perror("error : munmap");
+ }
+ close(_fd);
#endif
+}
+
+void TokenSource::sopen(const char *filename){
+ _cursor = 0;
+
+ _eof = false;
+
+#ifdef WIN32
+ _file.open(filename, ios::in);
+ fill_buffer();
+#else
+ if ((_fd = open(filename, O_RDONLY)) == -1){
+ perror("error : open file");
+ exit(-1);
+ }
+
+ struct stat buf;
+ if(fstat(_fd, &buf) == -1){
+ perror("error status file");
+ exit(-1);
+ }
+
+ _filesize = buf.st_size;
+
+
+
+ if ((_buffer = (char *)mmap(0, _filesize, PROT_READ, MAP_PRIVATE, _fd, 0)) == MAP_FAILED){
+ perror("error mmap");
+ exit(-1);
+ }
+#endif
+}
+
+#ifdef WIN32
+bool TokenSource::fill_buffer(){
+ if (_file.eof()){
+ return false;
+ }
+ else{
+ _file.read(_buffer, BUFFER_SIZE);
+ _buffer_size = _file.gcount();
+ return true;
+ }
+}
+#endif
+
+bool TokenSource::go_to_next_token(){
+ while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t'){
+ _cursor ++;
+#ifdef WIN32
+ if (_cursor >= _buffer_size){
+ if (!fill_buffer()){
+ return true;
+ }
+ _cursor = 0;
+ }
+#else
+ if(ensure_capacity())
+ break;
+#endif
+ }
+
+ return false;
+}
+
+
+void TokenSource::build_composite_token(){
+ _cursor ++;
+#ifdef WIN32
+ if (_cursor == _buffer_size){
+ if (!fill_buffer()){
+ cout << "found \" at end of file" << endl;
+ return;
+ }
+ _cursor = 0;
+ }
+#else
+ if (ensure_capacity()){
+ cout << "error :found \" at end of file" << endl;
+ return;
+ }
+#endif
+ do{
+ _token.push_back(_buffer[_cursor]);
+ _cursor ++;
+
+
+ if (ensure_capacity()){
+ break;
+ }
+
+ }
+ while(_buffer[_cursor] != '"');
+ _cursor ++;
+
+ ensure_capacity();
+}
+
+void TokenSource::build_simple_token(){
+ while(_buffer[_cursor] != ' ' && _buffer[_cursor] != '\n' && _buffer[_cursor] != '\t'){
+ _token.push_back(_buffer[_cursor]);
+ _cursor ++;
+
+
+ if (ensure_capacity()){
+ break;
+ }
+
+ }
+}
+
+bool TokenSource::ensure_capacity(){
+#ifdef WIN32
+ if (_cursor >= _buffer_size){
+ if (!fill_buffer()){
+ _eof = true;
+ return true;
+ }
+ _cursor = 0;
+ }
+ return false;
+#else
+ if (_cursor < _filesize)
+ return false;
+ _eof = true;
+ return true;
+#endif
+}
+
+void TokenSource::build_line_breaks(){
+ while(_buffer[_cursor] == '\n'){
+ _cursor ++;
+ if (ensure_capacity()){
+ break;
+ }
+ }
+ _token.push_back('\n');
+}
+
+void TokenSource::build_definition_starter(){
+ _cursor ++;
+ ensure_capacity();
+ _token.push_back('%');
+
+}
+
+std::string *TokenSource::lire_token(){
+ //regexp recognition
+ //a token is
+ //(1) a line break
+ //(2) composite : a char buffer delimited by \"
+ //(3) a char buffer delimited by space
+
+ if (!_token.empty())
+ _token.clear();
+
+ if (_eof){
+ return NULL;
+ }
+
+ if(go_to_next_token())
+ return NULL;
+
+ if (_buffer[_cursor] == '\n'){
+ build_line_breaks();
+ }
+ else if (_buffer[_cursor] == '%'){
+ build_definition_starter();
+ }
+ else if (_buffer[_cursor] != '"'){
+ build_simple_token();
+ }
+ else{
+ build_composite_token();
+ }
+
+
+
+ return &_token;
+}
diff --git a/parser/src/TokenSource.hpp b/parser/src/TokenSource.hpp
index 45cf69dab25d6c595a31ecb138d386871aa99b7c..ffa786dfe660901818f440aab0b389e3c8a9efac 100644
--- a/parser/src/TokenSource.hpp
+++ b/parser/src/TokenSource.hpp
@@ -1,12 +1,107 @@
#ifndef TOKENSOURCE_HPP
#define TOKENSOURCE_HPP
+#include
+#include
-#ifndef MAPPINGDENIED
-#include "TokenSource_mmap.hpp"
+#ifdef WIN32 // They do not have mmap
+ #define BUFFER_SIZE 2048
+ #define WORD_SIZE 64
+ #include
#else
-#include "TokenSource_fstream.hpp"
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
#endif
+/*!
+ * \class TokenSource
+ * \brief supply tokens from a file trace. Tokens are word unit used in PajeFile trace formats.
+ */
+class TokenSource{
+
+private:
+
+#ifdef WIN32
+ char _buffer[BUFFER_SIZE];
+#else
+ char* _buffer;
+#endif
+
+ std::string _token;
+ int _cursor;
+
+#ifdef WIN32
+ int _buffer_size;
+ bool _eof;
+ std::ifstream _file;
+#else
+ off_t _filesize;
+ bool _eof;
+ int _fd;
+#endif
+
+
+#ifdef WIN32
+ bool fill_buffer();
+#endif
+
+ bool go_to_next_token();
+ bool ensure_capacity();
+
+ void build_definition_starter();
+ void build_line_breaks();
+ void build_composite_token();
+ void build_simple_token();
+
+public:
+
+
+ /*!
+ * \fn TokenSource(const char* filename);
+ * \brief Constructor opening a file
+ * \param Valid filename
+ */
+ TokenSource(const char* filename);
+
+
+
+
+ /*!
+ * \fn TokenSource
+ * \brief This constructor needs a file to be openned
+ */
+ TokenSource();
+
+
+
+ /*!
+ * \fn open(const char *filename)
+ * \brief open a file
+ * \param valid filename
+ */
+ void sopen(const char *filename);
+
+
+
+ /*!
+ * \fn lire_token
+ * \brief supplies a token
+ * \return a \\0-ended character string (char*), NULL if the file ended, NULL if no file is opened
+ */
+ std::string* lire_token();
+
+
+ /*!
+ * \fn ~TokenSource
+ * \brief Destuctor which release the file
+ */
+ ~TokenSource();
+
+};
#endif // TOKENSOURCE_HPP
diff --git a/parser/src/TokenSource_fstream.cpp b/parser/src/TokenSource_fstream.cpp
deleted file mode 100644
index e5128f9392c66d70ad431e0c833c2966c200de96..0000000000000000000000000000000000000000
--- a/parser/src/TokenSource_fstream.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-#include "TokenSource.hpp"
-using namespace std;
-
-TokenSource::TokenSource(){
- //no file are opened
- //you must use open later
- _eof = true;
-}
-
-
-TokenSource::TokenSource(const char *filename){
- sopen(filename);
-}
-
-TokenSource::~TokenSource(){
- _file.close();
-}
-
-void TokenSource::sopen(const char *filename){
- _cursor = 0;
-
- _eof = false;
- _file.open(filename, ios::in);
- fill_buffer();
-}
-
-bool TokenSource::fill_buffer(){
- if (_file.eof()){
- return false;
- }
- else{
- _file.read(_buffer, BUFFER_SIZE);
- _buffer_size = _file.gcount();
- return true;
- }
-}
-
-bool TokenSource::go_to_next_token(){
- while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t'){
- _cursor ++;
- if (_cursor >= _buffer_size){
- if (!fill_buffer()){
- return true;
- }
- _cursor = 0;
- }
- }
- return false;
-}
-
-
-void TokenSource::build_composite_token(){
- _cursor ++;
- if (_cursor == _buffer_size){
- if (!fill_buffer()){
- cout << "found \" at end of file" << endl;
- return;
- }
- _cursor = 0;
- }
- do{
- _token.push_back(_buffer[_cursor]);
- _cursor ++;
-
-
- if (ensure_capacity()){
- break;
- }
-
- }
- while(_buffer[_cursor] != '"');
- _cursor ++;
-
- ensure_capacity();
-}
-
-void TokenSource::build_simple_token(){
- while(_buffer[_cursor] != ' ' && _buffer[_cursor] != '\n' && _buffer[_cursor] != '\t'){
- _token.push_back(_buffer[_cursor]);
- _cursor ++;
-
-
- if (ensure_capacity()){
- break;
- }
-
- }
-}
-
-bool TokenSource::ensure_capacity(){
- if (_cursor >= _buffer_size){
- if (!fill_buffer()){
- _eof = true;
- return true;
- }
- _cursor = 0;
- }
- return false;
-}
-
-void TokenSource::build_line_breaks(){
- while(_buffer[_cursor] == '\n'){
- _cursor ++;
- if (ensure_capacity()){
- break;
- }
- }
- _token.push_back('\n');
-}
-
-void TokenSource::build_definition_starter(){
- _cursor ++;
- ensure_capacity();
- _token.push_back('%');
-
-}
-
-std::string *TokenSource::lire_token(){
- //regexp recognition
- //a token is
- //(1) a line break
- //(2) composite : a char buffer delimited by \"
- //(3) a char buffer delimited by space
-
- if (!_token.empty())
- _token.clear();
-
- if (_eof){
- return NULL;
- }
-
- if(go_to_next_token())
- return NULL;
-
- if (_buffer[_cursor] == '\n'){
- build_line_breaks();
- }
- else if (_buffer[_cursor] == '%'){
- build_definition_starter();
- }
- else if (_buffer[_cursor] != '"'){
- build_simple_token();
- }
- else{
- build_composite_token();
- }
-
-
-
- return &_token;
-}
diff --git a/parser/src/TokenSource_fstream.hpp b/parser/src/TokenSource_fstream.hpp
deleted file mode 100644
index a9e4e57a8f9c92ba0957320d0b5332833894a1f2..0000000000000000000000000000000000000000
--- a/parser/src/TokenSource_fstream.hpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include
-#include
-#define BUFFER_SIZE 2048
-#define WORD_SIZE 64
-#include
-
-/*!
- * \class TokenSource
- * \brief supply tokens from a file trace. Tokens are word unit used in PajeFile trace formats.
- */
-class TokenSource{
-
-private:
-
- char _buffer[BUFFER_SIZE];
-
- std::string _token;
- int _cursor;
-
- int _buffer_size;
- bool _eof;
- std::ifstream _file;
-
- bool fill_buffer();
- bool go_to_next_token();
- bool ensure_capacity();
-
- void build_definition_starter();
- void build_line_breaks();
- void build_composite_token();
- void build_simple_token();
-
-public:
-
-
- /*!
- * \fn TokenSource(const char* filename);
- * \brief Constructor opening a file
- * \param Valid filename
- */
- TokenSource(const char* filename);
-
-
-
-
- /*!
- * \fn TokenSource
- * \brief This constructor needs a file to be openned
- */
- TokenSource();
-
-
-
- /*!
- * \fn open(const char *filename)
- * \brief open a file
- * \param valid filename
- */
- void sopen(const char *filename);
-
-
-
- /*!
- * \fn lire_token
- * \brief supplies a token
- * \return a \\0-ended character string (char*), NULL if the file ended, NULL if no file is opened
- */
- std::string* lire_token();
-
-
- /*!
- * \fn ~TokenSource
- * \brief Destuctor which release the file
- */
- ~TokenSource();
-
-};
-
-
diff --git a/parser/src/TokenSource_mmap.cpp b/parser/src/TokenSource_mmap.cpp
deleted file mode 100644
index 0ade7cee2232af8306f7466ea54ea19e0fdd5cc1..0000000000000000000000000000000000000000
--- a/parser/src/TokenSource_mmap.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-
-#include "TokenSource.hpp"
-
-using namespace std;
-
-
-TokenSource::TokenSource(){
- //no file are opened
- //you must use open later
- _eof = true;
-}
-
-
-TokenSource::TokenSource(const char *filename){
- sopen(filename);
-}
-
-
-
-TokenSource::~TokenSource(){
- if (munmap(_buffer,_filesize)==-1){
- perror("error : munmap");
- }
-
- close(_fd);
-
-}
-
-void TokenSource::sopen(const char *filename){
- _cursor = 0;
-
-
-
- _eof = false;
-
- if ((_fd=open(filename,O_RDONLY))==-1){
- perror("error : open file");
- exit(-1);
- }
-
- struct stat buf;
- if(fstat(_fd,&buf )==-1){
- perror("error status file");
- exit(-1);
- }
-
- _filesize = buf.st_size;
-
-
-
- if ((_buffer=(char *)mmap(0,_filesize,PROT_READ,MAP_PRIVATE,_fd,0))==MAP_FAILED){
- perror("error mmap");
- exit(-1);
- }
-
-
-}
-
-
-
-bool TokenSource::go_to_next_token(){
- while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t'){
- _cursor ++;
- if(ensure_capacity())
- break;
- }
- return false;
-}
-
-
-void TokenSource::build_composite_token(){
- _cursor ++;
- if (ensure_capacity()){
- cout << "error :found \" at end of file" << endl;
- return;
- }
-
-
- do{
- _token.push_back(_buffer[_cursor]);
- _cursor ++;
-
-
- if (ensure_capacity()){
- break;
- }
-
- }
- while(_buffer[_cursor] != '"');
- _cursor ++;
-
- ensure_capacity();
-}
-
-void TokenSource::build_simple_token(){
- while(_buffer[_cursor] != ' ' && _buffer[_cursor] != '\n' && _buffer[_cursor] != '\t'){
- _token.push_back(_buffer[_cursor]);
- _cursor ++;
-
-
- if (ensure_capacity()){
- break;
- }
-
- }
-}
-
-bool TokenSource::ensure_capacity(){
- if (_cursor < _filesize)
- return false;
- _eof = true;
- return true;
-}
-
-void TokenSource::build_line_breaks(){
- while(_buffer[_cursor] == '\n'){
- _cursor ++;
- if (ensure_capacity()){
- break;
- }
- }
- _token.push_back('\n');
-}
-
-void TokenSource::build_definition_starter(){
- _cursor ++;
- ensure_capacity();
- _token.push_back('%');
-
-}
-
-std::string *TokenSource::lire_token(){
- //regexp recognition
- //a token is
- //(1) a line break
- //(2) composite : a char buffer delimited by \"
- //(3) a char buffer delimited by space
-
- if (!_token.empty())
- _token.clear();
-
- if (_eof){
- return NULL;
- }
-
- if(go_to_next_token())
- return NULL;
-
- if (_buffer[_cursor] == '\n'){
- build_line_breaks();
- }
- else if (_buffer[_cursor] == '%'){
- build_definition_starter();
- }
- else if (_buffer[_cursor] != '"'){
- build_simple_token();
- }
- else{
- build_composite_token();
- }
-
-
-
- return &_token;
-}
-
diff --git a/parser/src/TokenSource_mmap.hpp b/parser/src/TokenSource_mmap.hpp
deleted file mode 100644
index 57b34dfd90db5f0f7a357eb6b6d4dfac172868fe..0000000000000000000000000000000000000000
--- a/parser/src/TokenSource_mmap.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/*!
- * \class TokenSource
- * \brief supply tokens from a file trace. Tokens are word unit used in PajeFile trace formats.
- */
-class TokenSource{
-
-private:
-
- char* _buffer;
-
- std::string _token;
- int _cursor;
-
- off_t _filesize;
- bool _eof;
- int _fd;
-
-
- bool go_to_next_token();
- bool ensure_capacity();
-
- void build_definition_starter();
- void build_line_breaks();
- void build_composite_token();
- void build_simple_token();
-
-public:
-
-
- /*!
- * \fn TokenSource(const char* filename);
- * \brief Constructor opening a file
- * \param Valid filename
- */
- TokenSource(const char* filename);
-
-
-
-
- /*!
- * \fn TokenSource
- * \brief This constructor needs a file to be openned
- */
- TokenSource();
-
-
-
- /*!
- * \fn open(const char *filename)
- * \brief open a file
- * \param valid filename
- */
- void sopen(const char *filename);
-
-
-
- /*!
- * \fn lire_token
- * \brief supplies a token
- * \return a \\0-ended character string (char*), NULL if the file ended, NULL if no file is opened
- */
- std::string* lire_token();
-
-
- /*!
- * \fn ~TokenSource
- * \brief Destuctor which release the file
- */
- ~TokenSource();
-
-};
-
-
-
diff --git a/trace/src/values/Color.cpp b/trace/src/values/Color.cpp
index a1213ddcfa5b3667fcac39c197ddeb10ee2ec594..7ddf8549a134017127c19b6d37c91a284262b249 100644
--- a/trace/src/values/Color.cpp
+++ b/trace/src/values/Color.cpp
@@ -15,17 +15,39 @@ Color::Color(double r, double g, double b) {
bool Color::instantiate(std::string &in, Color &out) {
double r, g, b;
- size_t position;
- while((position = in.find(',')) != -1) {
- std::string part1 = in.substr(0,position);
- std::string part2 = in.substr(position+1);
- in.assign(part1.append(".").append(part2));
+
+ if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) == 3){
+ out = Color(r, g, b);
+ return true;
+ }
+
+ // The error could occur because this is not the good format for decimal.
+ // Dots instead of commas or the contrary
+ bool commas_first = false;
+
+ if(replace_in_string(in, ',', '.')){
+ commas_first = true;
+ }
+
+ if(commas_first){ // We have dots now
+ if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) != 3){
+ return false;
+ }
+ else{
+ out = Color(r, g, b);
+ return true;
+ }
}
- if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) != 3){
- return false;
+ else{ // We had dots initially, we need to change them in commas
+ replace_in_string(in, '.', ',');
+ if(sscanf(in.c_str(), "%lf %lf %lf", &r, &g, &b) != 3){
+ return false;
+ }
+ else{
+ out = Color(r, g, b);
+ return true;
+ }
}
- out = Color(r, g, b);
- return true;
}
std::string Color::to_string() const {
@@ -33,3 +55,17 @@ std::string Color::to_string() const {
oss << _r << " " << _g << " " << _b;
return oss.str();
}
+
+
+bool Color::replace_in_string(std::string &characters, char to_replace, char replace_by) {
+ size_t position;
+ bool has_change = false;
+ while((position = characters.find(to_replace)) != std::string::npos) { // We had commas
+ std::string part1 = characters.substr(0, position);
+ std::string part2 = characters.substr(position+1);
+ characters = part1 + replace_by + part2;
+ has_change = true;
+ }
+
+ return has_change;
+}
diff --git a/trace/src/values/Color.hpp b/trace/src/values/Color.hpp
index d11aa92de864c6cfaa61094a517d54be1febd548..39b8c1a1f0cbd5dcf0e2aa0c5ec4187fe22d2b4e 100644
--- a/trace/src/values/Color.hpp
+++ b/trace/src/values/Color.hpp
@@ -59,6 +59,18 @@ public:
*/
std::string to_string() const;
+private:
+ /*!
+ *
+ * \fn replace_in_string(std::string &characters, char to_replace, char replace_by) const
+ * \brief Replace in the string the character to_replace by replace_by.
+ * \param characters string to be replaced.
+ * \param to_replace the character we want to replace.
+ * \param replace_by the character we use to replace the first one.
+ * \return true if there was a change.
+ *
+ */
+ static bool replace_in_string(std::string &characters, char to_replace, char replace_by);
};