You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(27) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(10) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(2) |
From: Knut F. <Knu...@gm...> - 2010-11-24 07:21:07
|
[2010-11-14 23:54] Knut Franke <Knu...@gm...>: > Since the API is not backwards-compatible with the last version released on > proindependent.com (not to mention liborigin1), we already should have > bumped the major version of the last release. See http://semver.org/. I > think we should do that at least now, i.e. jump to 2.0.0 and do any > further API- incompatible changes on a separate development branch to be > released as liborigin3. Failing to receive any feedback on this, I've gone forward and adjusted the versioning scheme accordingly. Last chance to complain before it ends up in a release. ;-) Also, I've added a mailing list liborigin-git which will (if I set everything up correctly) receive automatic notifications about changes to the Git repository. Knut |
From: Knut F. <Knu...@gm...> - 2010-11-14 23:04:34
|
Committed up to here. |
From: Knut F. <Knu...@gm...> - 2010-11-14 22:54:32
|
[2010-11-12 14:56] Miquel Garriga <gbm...@gm...>: > Get a shared library with higher version than last released. [...] > -set_target_properties(origin2 PROPERTIES VERSION 0.0.1 SOVERSION 0 ) > +set_target_properties(origin2 PROPERTIES VERSION 1.0.1 SOVERSION 1 ) Since the API is not backwards-compatible with the last version released on proindependent.com (not to mention liborigin1), we already should have bumped the major version of the last release. See http://semver.org/. I think we should do that at least now, i.e. jump to 2.0.0 and do any further API- incompatible changes on a separate development branch to be released as liborigin3. Knut |
From: Miquel G. <gbm...@gm...> - 2010-11-12 13:58:10
|
With these changes the obtained opjfile.log file is (almost) identical to that obtained by release liborigin2-13092010.zip. --- Origin700Parser.cpp | 6 ++-- Origin750Parser.cpp | 54 +++++++++++++++++++++++++------------------------- Origin800Parser.cpp | 32 +++++++++++++++--------------- OriginFile.cpp | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Origin700Parser.cpp b/Origin700Parser.cpp index 029e8ca..33627be 100644 --- a/Origin700Parser.cpp +++ b/Origin700Parser.cpp @@ -55,7 +55,7 @@ bool Origin700Parser::parse() file >> size; file.seekg(1, ios_base::cur); - LOG_PRINT(logfile, " [column found = %d/0x%X @ 0x%X]\n", size, size, (unsigned int) file.tellg()) + LOG_PRINT(logfile, " [column found = %d/0x%X @ 0x%X]\n", size, size, (unsigned int) file.tellg()) unsigned int colpos = file.tellg(); unsigned int current_col = 1, nr = 0, nbytes = 0; @@ -387,7 +387,7 @@ bool Origin700Parser::parse() unsigned int POS = (unsigned int)file.tellg()-11; LOG_PRINT(logfile, "\nHEADER SECTION\n") - LOG_PRINT(logfile, " nr_spreads = %d", speadSheets.size()) + LOG_PRINT(logfile, " nr_spreads = %d\n", speadSheets.size()) LOG_PRINT(logfile, " [position @ 0x%X]\n", POS) //////////////////////// OBJECT INFOS ////////////////////////////////////// @@ -476,7 +476,7 @@ void Origin700Parser::readMatrixInfo() // LAYER section LAYER += 0x5; - + unsigned short width; file.seekg(LAYER + 0x27, ios_base::beg); file >> width; diff --git a/Origin750Parser.cpp b/Origin750Parser.cpp index 7b3052b..2a29b53 100644 --- a/Origin750Parser.cpp +++ b/Origin750Parser.cpp @@ -1,7 +1,7 @@ /*************************************************************************** File : Origin750Parser.cpp -------------------------------------------------------------------- - Copyright : (C) 2007-2008 Alex Kargovsky, Stefan Gerlach, + Copyright : (C) 2007-2008 Alex Kargovsky, Stefan Gerlach, Ion Vasilief Email (use @ for *) : kargovsky*yumr.phys.msu.su, ion_vasilief*yahoo.fr Description : Origin 7.5 file parser class @@ -61,11 +61,11 @@ bool Origin750Parser::parse() file >> size; file.seekg(1, ios_base::cur); - LOG_PRINT(logfile, " [column found = %d/0x%X @ 0x%X]\n", size, size, (unsigned int) file.tellg()) + LOG_PRINT(logfile, " [column found = %d/0x%X @ 0x%X]\n", size, size, (unsigned int) file.tellg()) unsigned int colpos = file.tellg(); unsigned int current_col = 1, nr = 0, nbytes = 0; - + while(size > 0 && size < 0x84) { // should be 0x72, 0x73 or 0x83 //////////////////////////////// COLUMN HEADER ///////////////////////////////////////////// short data_type; @@ -77,7 +77,7 @@ bool Origin750Parser::parse() file.seekg(oldpos + 0x3F, ios_base::beg); file >> data_type_u; - + char valuesize; file.seekg(oldpos + 0x3D, ios_base::beg); file >> valuesize; @@ -151,7 +151,7 @@ bool Origin750Parser::parse() case 0x6001://double for(unsigned int i = 0; i < size; ++i) { - double value; + double value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -161,7 +161,7 @@ bool Origin750Parser::parse() case 0x6003://float for(unsigned int i = 0; i < size; ++i) { - float value; + float value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -173,7 +173,7 @@ bool Origin750Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - unsigned int value; + unsigned int value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -184,7 +184,7 @@ bool Origin750Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - int value; + int value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -197,7 +197,7 @@ bool Origin750Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - unsigned short value; + unsigned short value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -208,7 +208,7 @@ bool Origin750Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - short value; + short value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -221,7 +221,7 @@ bool Origin750Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - unsigned char value; + unsigned char value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -232,7 +232,7 @@ bool Origin750Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - char value; + char value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -409,7 +409,7 @@ bool Origin750Parser::parse() unsigned int POS = (unsigned int)file.tellg()-11; LOG_PRINT(logfile, "\nHEADER SECTION\n") - LOG_PRINT(logfile, " nr_spreads = %d", speadSheets.size()) + LOG_PRINT(logfile, " nr_spreads = %d\n", speadSheets.size()) LOG_PRINT(logfile, " [position @ 0x%X]\n", POS) //////////////////////// OBJECT INFOS ////////////////////////////////////// @@ -443,12 +443,12 @@ bool Origin750Parser::parse() } file.seekg(1, ios_base::cur); - LOG_PRINT(logfile, "Some Origin params @ 0x%X:", (unsigned int)file.tellg()) + LOG_PRINT(logfile, "Some Origin params @ 0x%X:\n", (unsigned int)file.tellg()) file >> c; while(c != 0) { - LOG_PRINT(logfile, " ") + LOG_PRINT(logfile, " ") while(c != '\n') { LOG_PRINT(logfile, "%c", c) @@ -456,7 +456,7 @@ bool Origin750Parser::parse() } double parvalue; file >> parvalue; - LOG_PRINT(logfile, ": %g", parvalue); + LOG_PRINT(logfile, ": %g\n", parvalue); file.seekg(1, ios_base::cur); file >> c; @@ -525,7 +525,7 @@ bool Origin750Parser::parse() notes.back().frameRect = rect; notes.back().creationDate = doubleToPosixTime(creationDate); notes.back().modificationDate = doubleToPosixTime(modificationDate); - + if(c & 0x01) notes.back().title = Window::Label; else if(c & 0x02) @@ -650,7 +650,7 @@ void Origin750Parser::readSpreadInfo() } /////////////// COLUMN Types /////////////////////////////////////////// - LOG_PRINT(logfile, " Spreadsheet has %d columns", speadSheets[spread].columns.size()) + LOG_PRINT(logfile, " Spreadsheet has %d columns\n", speadSheets[spread].columns.size()) vector<SpreadColumn> header; while(1) @@ -868,7 +868,7 @@ void Origin750Parser::readExcelInfo() LAYER += 0x5; /////////////// COLUMN Types /////////////////////////////////////////// - LOG_PRINT(logfile, " Excel sheet %d has %d columns", isheet, excels[iexcel].sheets[isheet].columns.size()) + LOG_PRINT(logfile, " Excel sheet %d has %d columns\n", isheet, excels[iexcel].sheets[isheet].columns.size()) while(1) { @@ -1048,7 +1048,7 @@ void Origin750Parser::readMatrixInfo() // LAYER section LAYER += 0x5; - + file.seekg(LAYER + 0x2B, ios_base::beg); file >> matrixes[idx].columnCount; @@ -1155,7 +1155,7 @@ void Origin750Parser::readMatrixInfo() } LAYER += 0x1E7 + 0x1; - + file.seekg(LAYER, ios_base::beg); file >> size; @@ -1871,7 +1871,7 @@ void Origin750Parser::readGraphInfo() file.seekg(LAYER + 0x13, ios_base::beg); file >> h; - curve.surface.backColorEnabled = (h & 0x08); + curve.surface.backColorEnabled = (h & 0x08); file.seekg(LAYER + 0x15A, ios_base::beg); file >> curve.surface.backColor; file >> curve.surface.xSideWallColor; @@ -1965,7 +1965,7 @@ void Origin750Parser::readGraphInfo() file >> size; LAYER += size + (size > 0 ? 0x1 : 0) + 0x5; - + file.seekg(LAYER, ios_base::beg); file >> size; @@ -2034,7 +2034,7 @@ void Origin750Parser::readGraphInfo() void Origin750Parser::readGraphGridInfo(GraphGrid& grid) { unsigned int POS = file.tellg(); - + unsigned char h; short w; @@ -2065,7 +2065,7 @@ void Origin750Parser::readGraphAxisBreakInfo(GraphAxisBreak& axis_break) file >> axis_break.to; file >> axis_break.scaleIncrementAfter; - + file >> axis_break.position; unsigned char h; @@ -2141,7 +2141,7 @@ void Origin750Parser::readGraphAxisTickLabelsInfo(GraphAxisTick& tick) file.seekg(POS + 0x1A, ios_base::beg); file >> h; tick.fontBold = (h & 0x08); - + file.seekg(POS + 0x23, ios_base::beg); file >> w; file >> h; @@ -2363,7 +2363,7 @@ void Origin750Parser::readWindowProperties(Window& window, unsigned int size) { LOG_PRINT(logfile, " WINDOW %d NAME : %s is hidden\n", objectIndex, window.name.c_str()) } - + double creationDate, modificationDate; file.seekg(POS + 0x73, ios_base::beg); file >> creationDate; diff --git a/Origin800Parser.cpp b/Origin800Parser.cpp index 7a0e869..708ee6c 100644 --- a/Origin800Parser.cpp +++ b/Origin800Parser.cpp @@ -61,11 +61,11 @@ bool Origin800Parser::parse() file >> size; file.seekg(1, ios_base::cur); - LOG_PRINT(logfile, " [column found = %d/0x%X @ 0x%X]\n", size, size, (unsigned int) file.tellg()) + LOG_PRINT(logfile, " [column found = %d/0x%X @ 0x%X]\n", size, size, (unsigned int) file.tellg()) unsigned int colpos = file.tellg(); unsigned int current_col = 1, nr = 0, nbytes = 0; - + while(size > 0 && size <= 0x8C){// should be 0x72, 0x73 or 0x83 ? //////////////////////////////// COLUMN HEADER ///////////////////////////////////////////// @@ -78,7 +78,7 @@ bool Origin800Parser::parse() file.seekg(oldpos + 0x3F, ios_base::beg); file >> data_type_u; - + char valuesize; file.seekg(oldpos + 0x3D, ios_base::beg); file >> valuesize; @@ -161,7 +161,7 @@ bool Origin800Parser::parse() case 0x6001://double for(unsigned int i = 0; i < size; ++i) { - double value; + double value; file >> value; matrixes.back().data.push_back((double)value); //if (size < 100) @@ -171,7 +171,7 @@ bool Origin800Parser::parse() case 0x6003://float for(unsigned int i = 0; i < size; ++i) { - float value; + float value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -183,7 +183,7 @@ bool Origin800Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - unsigned int value; + unsigned int value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -194,7 +194,7 @@ bool Origin800Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - int value; + int value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -207,7 +207,7 @@ bool Origin800Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - unsigned short value; + unsigned short value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -218,7 +218,7 @@ bool Origin800Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - short value; + short value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -231,7 +231,7 @@ bool Origin800Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - unsigned char value; + unsigned char value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -242,7 +242,7 @@ bool Origin800Parser::parse() { for(unsigned int i = 0; i < size; ++i) { - char value; + char value; file >> value; matrixes.back().data.push_back((double)value); if (size < 100) @@ -416,7 +416,7 @@ bool Origin800Parser::parse() unsigned int POS = (unsigned int)file.tellg()-11; LOG_PRINT(logfile, "\nHEADER SECTION\n") - LOG_PRINT(logfile, " nr_spreads = %d", speadSheets.size()) + LOG_PRINT(logfile, " nr_spreads = %d\n", speadSheets.size()) LOG_PRINT(logfile, " [position @ 0x%X]\n", POS) POS += 0xB; @@ -1008,7 +1008,7 @@ void Origin800Parser::readMatrixInfo() // LAYER section LAYER += 0x5; - + file.seekg(LAYER + 0x2B, ios_base::beg); file >> matrixes[idx].columnCount; LOG_PRINT(logfile, " Columns: %d (@ 0x%X)\n", matrixes[idx].columnCount, (LAYER + 0x2B)) @@ -1798,7 +1798,7 @@ void Origin800Parser::readGraphInfo() file.seekg(LAYER + 0x13, ios_base::beg); file >> h; - curve.surface.backColorEnabled = (h & 0x08); + curve.surface.backColorEnabled = (h & 0x08); file.seekg(LAYER + 0x15A, ios_base::beg); file >> curve.surface.backColor; file >> curve.surface.xSideWallColor; @@ -1894,7 +1894,7 @@ void Origin800Parser::readGraphInfo() file >> newSize; LAYER += newSize + (newSize > 0 ? 0x1 : 0) + 0x5; - + file.seekg(LAYER, ios_base::beg); file >> newSize; @@ -1977,7 +1977,7 @@ void Origin800Parser::skipObjectInfo() file >> size; POS = file.tellg(); } - + unsigned int nextSize = size; LOG_PRINT(logfile, " skipObjectInfo() size: %d (0x%X) @ 0x%X\n", size, size, POS) while (POS < d_file_size && nextSize == size){ diff --git a/OriginFile.cpp b/OriginFile.cpp index e1928a3..b3fee60 100644 --- a/OriginFile.cpp +++ b/OriginFile.cpp @@ -60,7 +60,7 @@ OriginFile::OriginFile(const string& fileName) fileVersion = atoi(vers.c_str()); file.close(); - LOG_PRINT(logfile, " [version = %d]\n", fileVersion) + LOG_PRINT(logfile, " [version = %d]\n", fileVersion) buildVersion = fileVersion; // translate version -- 1.7.3 |
From: Miquel G. <gbm...@gm...> - 2010-11-12 13:58:09
|
Get a shared library with higher version than last released. --- CMakeLists.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c321500..7aa3712 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ set (devel-headers # dynamic library add_library (origin2 SHARED ${sources}) -set_target_properties(origin2 PROPERTIES VERSION 0.0.1 SOVERSION 0 ) +set_target_properties(origin2 PROPERTIES VERSION 1.0.1 SOVERSION 1 ) # static library add_library (origin2-static STATIC ${sources}) -- 1.7.3 |
From: Miquel G. <gbm...@gm...> - 2010-11-12 13:58:04
|
Instead of breaking out of parse process, skip sections that cannot be handled. --- Origin610Parser.cpp | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Origin610Parser.cpp b/Origin610Parser.cpp index 2b83d58..eb24861 100644 --- a/Origin610Parser.cpp +++ b/Origin610Parser.cpp @@ -1013,8 +1013,33 @@ bool Origin610Parser::readGraphInfo() //if (!QString(sec_name.c_str()).trimmed().isEmpty()) if (!sec_name.empty()) sectionNames.push_back(sec_name); - else - break; + else { + // section has no name, just skip it + LAYER += size + 0x01; + // skip header data + file.seekg(LAYER, ios_base::beg); + // get size of block_1 data + file >> size; + LAYER += 0x5 + size + 0x1; + // skip block_1 + file.seekg(LAYER, ios_base::beg); + // get size of block_2 data + file >> size; + LAYER += 0x5 + size + (size > 0 ? 0x1 : 0); + // skip block_2 + file.seekg(LAYER, ios_base::beg); + // get size of block_3 data + file >> size; + LAYER += 0x5 + size + (size > 0 ? 0x1 : 0); + // skip block_3 + file.seekg(LAYER, ios_base::beg); + file >> size; + // if it is last section jump out + if (!size || size != sectionSize) + break; + // if not, continue with next section + continue; + } unsigned int sectionNamePos = LAYER + 0x46; LOG_PRINT(logfile, " SECTION NAME: %s (@ 0x%X)\n", sec_name.c_str(), (LAYER + 0x46)) -- 1.7.3 |
From: Knut F. <Knu...@gm...> - 2010-11-10 18:27:56
|
Okay; since the patches are definitely an improvement and even include some comments explaining the weird behaviour, I won't let better be the enemy of good. Committed. However, this bug raises a more general question to keep in mind for the generalized parser: [2010-11-10 09:25] Miquel Garriga <gbm...@gm...>: > 2010/11/10 Knut Franke <Knu...@gm...>: > > What findStringPos() *should* do is guarantee that the read position does > > not change (i.e. seekg(startPos) before any return) and clearly indicate > > failure. There are different conventions for that (-1, a special value a > > la std::string::npos, returning bool or error code and writing the > > actual result to a pointer as offered by the GSL, throwing an > > exception). I think it would help if we could try to stick to one such > > convention. > > Yes, you are right, but, since the generalized parser will not need > findStringPos() > at all, Maybe; but it will definitely need some kind of error handling for cases where a (possibly corrupted, or unsupported) file is not parsable by some (internal) function. Having a set convention would help avoid bugs like these, where findStringPos() returns the position of the last byte in the file in case of failure, while callers variously expect -1, expect the read position to be at EOF or ignore this case altogether. Personally I think that exceptions would provide a good error-signalling convention. Maybe this particular example is a corner case, since very similar methods in the STL use the magic value std::string::npos. > You should not return -1 in an > unsigned int, Of course, with that convention the return type needs to be changed. > However, I would better spend time in the generalized parser that > finding a good patch > for each bug in OriginNNNParser. Fair enough. Knut |
From: Miquel G. <gbm...@gm...> - 2010-11-10 08:25:26
|
2010/11/10 Knut Franke <Knu...@gm...>: > > What findStringPos() *should* do is guarantee that the read position does not > change (i.e. seekg(startPos) before any return) and clearly indicate failure. > There are different conventions for that (-1, a special value a la > std::string::npos, returning bool or error code and writing the actual result > to a pointer as offered by the GSL, throwing an exception). I think it would > help if we could try to stick to one such convention. Yes, you are right, but, since the generalized parser will not need findStringPos() at all, I saw no need to enhance it. You should not return -1 in an unsigned int, unless you use it to represent the largest available unsigned int. On the other hand <cstring> header uses string::npos = static_cast<size_type>(-1). In the case of findStringPos, I agree that a better patch would be: size_t Origin800Parser::findStringPos(const string& name) { ... return std::string::npos; } since to represent a position is what size_t is designed for. However, I would better spend time in the generalized parser that finding a good patch for each bug in OriginNNNParser. Miquel |
From: Knut F. <Knu...@gm...> - 2010-11-10 07:43:39
|
[2010-11-10 00:02] Miquel Garriga <gbm...@gm...>: > Function Origin800Parser::findStringPos when the passed string > is not found leaves the 'get pointer' of file close to (but not at) > the EOF. Patches solve possible problems derived from this. To be precise, the patches resolve *some* of the problems caused by this. There are definitely more bugs lurking in the general vicinity. I'd say the problem is really findStringPos(). If it finds the string searched for, it seeks to the position where the search started and returns the position where the match occured, but if the string is *not* found, it leaves the file almost (but not quite) at EOF and returns that position. Nobody, apparantly including the authors of that code, would expect that. Just search through the callers of findStringPos and see how many of them handle the case of not finding the string correctly (without your patches, I'm counting zero of them). What findStringPos() *should* do is guarantee that the read position does not change (i.e. seekg(startPos) before any return) and clearly indicate failure. There are different conventions for that (-1, a special value a la std::string::npos, returning bool or error code and writing the actual result to a pointer as offered by the GSL, throwing an exception). I think it would help if we could try to stick to one such convention. Knut |
From: Miquel G. <gbm...@gm...> - 2010-11-09 23:10:15
|
--- Origin800Parser.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Origin800Parser.cpp b/Origin800Parser.cpp index 374e0a3..3181a9b 100644 --- a/Origin800Parser.cpp +++ b/Origin800Parser.cpp @@ -844,7 +844,9 @@ void Origin800Parser::readColumnInfo(int spread, int i) LOG_PRINT(logfile, " Column %s\n", colName.c_str()) unsigned int pos = findStringPos(colName); - if (file.eof()) + // even if colName was not found we are not yet at eof, + // just before it. We cannot use file.eof() + if (!(pos < d_file_size)) return; file.seekg(pos - 1, ios_base::beg); -- 1.7.3 |
From: Miquel G. <gbm...@gm...> - 2010-11-09 23:09:01
|
Function Origin800Parser::findStringPos when the passed string is not found leaves the 'get pointer' of file close to (but not at) the EOF. Patches solve possible problems derived from this. Miquel |
From: Miquel G. <gbm...@gm...> - 2010-11-09 23:03:30
|
--- Origin610Parser.cpp | 8 ++++++++ Origin700Parser.cpp | 5 +++++ Origin800Parser.cpp | 8 ++++++++ 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/Origin610Parser.cpp b/Origin610Parser.cpp index ddacd8f..2b83d58 100644 --- a/Origin610Parser.cpp +++ b/Origin610Parser.cpp @@ -436,6 +436,11 @@ bool Origin610Parser::parse() } readNotes(); + // If file has no Note windows, last function will read to EOF, + // skipping the info for ResultsLog and ProjectTree. + // As we know there is always a ResultsLog window after the Note + // windows, we better rewind to the start of Notes + file.seekg(POS, ios_base::beg); readResultsLog(); file.seekg(1 + 4*5 + 0x10 + 1, ios_base::cur); @@ -454,6 +459,9 @@ bool Origin610Parser::parse() void Origin610Parser::readNotes() { unsigned int pos = findStringPos("@"); + // if we are at end of file don't try to read a Note + if (!(pos < d_file_size)) + return; file.seekg(pos, ios_base::beg); unsigned int sectionSize; diff --git a/Origin700Parser.cpp b/Origin700Parser.cpp index 8f70ed0..029e8ca 100644 --- a/Origin700Parser.cpp +++ b/Origin700Parser.cpp @@ -419,6 +419,11 @@ bool Origin700Parser::parse() } readNotes(); + // If file has no Note windows, last function will read to EOF, + // skipping the info for ResultsLog and ProjectTree. + // As we know there is always a ResultsLog window after the Note + // windows, we better rewind to the start of Notes + file.seekg(POS, ios_base::beg); readResultsLog(); file.seekg(1 + 4*5 + 0x10 + 1, ios_base::cur); diff --git a/Origin800Parser.cpp b/Origin800Parser.cpp index 6dfed47..374e0a3 100644 --- a/Origin800Parser.cpp +++ b/Origin800Parser.cpp @@ -447,6 +447,11 @@ bool Origin800Parser::parse() } readNotes(); + // If file has no Note windows, last function will read to EOF, + // skipping the info for ResultsLog and ProjectTree. + // As we know there is always a ResultsLog window after the Note + // windows, we better rewind to the start of Notes + file.seekg(POS, ios_base::beg); readResultsLog(); file.seekg(1 + 4*5 + 0x10 + 1, ios_base::cur); @@ -465,6 +470,9 @@ bool Origin800Parser::parse() void Origin800Parser::readNotes() { unsigned int pos = findStringPos(notes_pos_mark); + // if we are at end of file don't try to read a Note + if (!(pos < d_file_size)) + return; file.seekg(pos, ios_base::beg); unsigned int sectionSize; -- 1.7.3 |
From: Knut F. <Knu...@gm...> - 2010-11-07 10:53:34
|
I've committed your patches, except for 1 (in the hope that we can agree not to maintain two repositories) and 2 (since I think it makes little sense to update the version number somewhere between releases). With both opj2dat and CMake buildfile (from the days of liborigin1) back in place, I think we have a good basis for the next big changes. :-) One thing we still need to figure out is the best procedure for submitting patches; copy-pasting them to an email client can easily break them: [2010-11-05 00:13] Miquel Garriga <gbm...@gm...>: > diff --git a/README b/README [...] > + CMake is available at http://www.cmake.org/ > ^ leading space (diff format) was missing from empty context lines... > -After installing qmake and the BOOST C++ library headers on your > system, issue the following commands: ... and long lines got word-wrapped. I had to manually edit the patches to fix these, which could get tedious for larger patches. Maybe you can teach your mail client not to munge the patches, or you could try git send-email (git help send-email even has a section explaining how to set it up for gmail). Knut |
From: Knut F. <Knu...@gm...> - 2010-11-05 07:38:45
|
[2010-11-05 00:13] Miquel Garriga <gbm...@gm...>: > --- > README | 12 +++++++----- > 1 files changed, 7 insertions(+), 5 deletions(-) I think we can squash this with the previous patch (switch from qmake to CMake), since the two make relatively little sense on their own. Knut |
From: Knut F. <Knu...@gm...> - 2010-11-05 07:33:24
|
[2010-11-05 00:09] Miquel Garriga <gbm...@gm...>: > -/* version 0.0 2007-09-26 */ > -#define LIBORIGIN_VERSION 0x00070926 > -#define LIBORIGIN_VERSION_STRING "2007-09-26" > +/* version 0.0 2010-10-29 */ > +#define LIBORIGIN_VERSION 0x00101029 > +#define LIBORIGIN_VERSION_STRING "2010-10-29" Oops, should have been in the last release. I think you sent this update before, but I managed to miss this one. Ideally though, it should be updated shortly before release so as to match the version number of the tarball. Which raises the question: How do we coordinate version bumps and releases? Can/should the current time stamp be inserted semi-automatically ("make release"), or should this be done manually shortly before release? I've made some good experiences with "git describe --tags --dirty --always" (plus a little magic to make it work also for release tarballs); however, this still requires "git tag `date --iso`" to be done before release, unless you want to change the versioning scheme. Knut |
From: Knut F. <Knu...@gm...> - 2010-11-05 07:13:27
|
[2010-11-05 00:07] Miquel Garriga <gbm...@gm...>: > First, remove the no longer needed "logging.hpp". It's already removed from the Git repository[1] (only SVN got screwed up); maybe we can continue from there and remove/disable/deprecate SVN. Knut [1] http://liborigin.git.sourceforge.net/git/gitweb.cgi?p=liborigin/liborigin;a=tree |
From: Miquel G. <gbm...@gm...> - 2010-11-04 23:13:57
|
--- README | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README b/README index b28dfa5..098520c 100644 --- a/README +++ b/README @@ -17,13 +17,15 @@ DEPENDENCIES: to compile, liborigin2 (still) depends on Note that the BOOST libraries are not needed at run time, neither are linked in the executable. --------------------------------------------------------------------------- -COMPILING: liborigin2 uses qmake for the building process. - qmake is part of a Qt distribution: http://trolltech.com/ +COMPILING: liborigin2 uses CMake for the building process. + CMake is available at http://www.cmake.org/ -After installing qmake and the BOOST C++ library headers on your system, issue the following commands: - $ qmake +After installing CMake and the BOOST C++ library headers on your system, issue the following commands: + $ mkdir build + $ cd build + $ cmake ../ $ make - $ make staticlib + $ make install --------------------------------------------------------------------------- FEATURES : -- 1.7.3 |
From: Miquel G. <gbm...@gm...> - 2010-11-04 23:12:55
|
Change to CMake build system to allow easier handling of additional command line utilities. --- CMakeLists.txt | 47 +++++++++++++++++++++++++++++++++++++++++++++++ liborigin2.pro | 34 ---------------------------------- 2 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 liborigin2.pro diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c321500 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,47 @@ +# CMakeLists.txt for liborigin2 +cmake_minimum_required(VERSION 2.8) + +# boost library headers +find_package(Boost REQUIRED) +include_directories(${Boost_INCLUDE_DIRS}) + +# source files +set (sources + OriginFile.cpp + OriginParser.cpp + OriginDefaultParser.cpp + Origin600Parser.cpp + Origin610Parser.cpp + Origin700Parser.cpp + Origin750Parser.cpp + Origin800Parser.cpp + Origin810Parser.cpp + ) + +# header files for development +set (devel-headers + OriginObj.h + OriginFile.h + OriginParser.h + tree.hh + ) + +# dynamic library +add_library (origin2 SHARED ${sources}) +set_target_properties(origin2 PROPERTIES VERSION 0.0.1 SOVERSION 0 ) + +# static library +add_library (origin2-static STATIC ${sources}) +set_target_properties(origin2-static PROPERTIES OUTPUT_NAME "origin2") + +# install libraries +install(TARGETS origin2 origin2-static DESTINATION lib) + +# install headers +install(FILES ${devel-headers} DESTINATION include) + +# command line util +add_executable(opj2dat opj2dat.cpp) +target_link_libraries (opj2dat origin2-static) + +install(TARGETS opj2dat DESTINATION bin) diff --git a/liborigin2.pro b/liborigin2.pro deleted file mode 100644 index 50f4006..0000000 --- a/liborigin2.pro +++ /dev/null @@ -1,34 +0,0 @@ -TARGET = origin2 -TEMPLATE = lib -CONFIG += warn_on release thread -#CONFIG += staticlib -MOC_DIR = ./tmp -OBJECTS_DIR = ./tmp - -DESTDIR = ./ - -# Path to the folder where the header files of the BOOST C++ libraries are installed -INCLUDEPATH += ../boost - -HEADERS += endianfstream.hh \ - tree.hh \ - OriginObj.h \ - OriginFile.h \ - OriginParser.h \ - OriginDefaultParser.h \ - Origin600Parser.h \ - Origin610Parser.h \ - Origin700Parser.h \ - Origin750Parser.h \ - Origin800Parser.h \ - Origin810Parser.h - -SOURCES += OriginFile.cpp \ - OriginParser.cpp \ - OriginDefaultParser.cpp \ - Origin600Parser.cpp \ - Origin610Parser.cpp \ - Origin700Parser.cpp \ - Origin750Parser.cpp \ - Origin800Parser.cpp \ - Origin810Parser.cpp -- 1.7.3 |
From: Miquel G. <gbm...@gm...> - 2010-11-04 23:10:22
|
--- opj2dat.cpp | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-) create mode 100644 opj2dat.cpp diff --git a/opj2dat.cpp b/opj2dat.cpp new file mode 100644 index 0000000..1745624 --- /dev/null +++ b/opj2dat.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + File : opj2dat.cpp + -------------------------------------------------------------------- + Copyright : (C) 2008 Stefan Gerlach + Email (use @ for *) : stefan.gerlach*uni-konstanz.de + Description : Origin project converter + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ + +#include "OriginFile.h" +#include <cstdio> +#include <cmath> +#include <cstring> +#include <string.h> + +int main(int argc, char *argv[]) { + if(argc != 2) { + printf("Usage : ./opj2dat <file.opj>\n"); + return -1; + } + + printf("opj2dat %s, Copyright (C) 2008 Stefan Gerlach\n",LIBORIGIN_VERSION_STRING); + + if(!strcmp(argv[1],"-v")) + return 0; + + OriginFile opj(argv[1]); + int status = opj.parse(); + printf("Parsing status = %d\n",status); + printf("OPJ PROJECT \"%s\" VERSION = %.2f\n",argv[1],opj.version()); + + printf("number of spreadsheets = %d\n",opj.spreadCount()); + printf("number of matrixes = %d\n",opj.matrixCount()); + printf("number of functions = %d\n",opj.functionCount()); + printf("number of graphs = %d\n",opj.graphCount()); + printf("number of notes = %d\n",opj.noteCount()); + for (unsigned int s=0;s<opj.spreadCount();s++) { + Origin::SpreadSheet spread = opj.spread(s); + int columnCount=spread.columns.size(); + printf("Spreadsheet %d :\n", s+1); + printf(" Name: %s\n",spread.name.c_str()); + printf(" Label: %s\n",spread.label.c_str()); + printf(" Columns: %d\n",columnCount); + for (int j=0;j<columnCount;j++) { + Origin::SpreadColumn column = spread.columns[j]; + printf(" Column %d : %s / type : %d, rows : %d\n", + j+1,column.name.c_str(),column.type,spread.maxRows); + } + FILE *out; + char * filename; + int ioret; +#ifndef WIN32 + ioret=asprintf(&filename,"%s.%d.dat",argv[1],s+1); +#else + ioret=asprintf(&filename,"%s.%d.dat",basename(argv[1]),s+1); +#endif + printf("saved to %s\n",filename); + if((out=fopen(filename,"w")) == NULL ) { + printf("Could not open %s",filename); + return -1; + } + // header + for (int j=0;j<columnCount;j++) { + fprintf(out,"%s ",spread.columns[j].name.c_str()); + printf("%s ",spread.columns[j].name.c_str()); + } + fprintf(out,"\n"); + printf("\n Data: \n"); + // data + for (int i=0;i<(int)spread.maxRows;i++) { + for (int j=0;j<columnCount;j++) { + if (i<(int)spread.columns[j].data.size()) { + Origin::variant value=spread.columns[j].data[i]; + if(spread.columns[j].type == Origin::SpreadColumn::Label) { + fprintf(out,"%s ",boost::get<string>(spread.columns[j].data[i]).c_str()); + } else { + double v=0.; + if (value.type() == typeid(double)) { + v = boost::get<double>(value); + if(fabs(v)>2.0e-300) { + fprintf(out,"%g ",v); + } + } + if (value.type() == typeid(string)) { + fprintf(out,"%s ",boost::get<string>(value).c_str()); + } + } + } + } + fprintf(out,"\n"); + } + fclose(out); + } + return 0; +} + -- 1.7.3 |
From: Miquel G. <gbm...@gm...> - 2010-11-04 23:09:08
|
--- OriginFile.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OriginFile.h b/OriginFile.h index 6636cc3..979df74 100644 --- a/OriginFile.h +++ b/OriginFile.h @@ -30,9 +30,9 @@ #ifndef ORIGIN_FILE_H #define ORIGIN_FILE_H -/* version 0.0 2007-09-26 */ -#define LIBORIGIN_VERSION 0x00070926 -#define LIBORIGIN_VERSION_STRING "2007-09-26" +/* version 0.0 2010-10-29 */ +#define LIBORIGIN_VERSION 0x00101029 +#define LIBORIGIN_VERSION_STRING "2010-10-29" #include "OriginObj.h" #include "OriginParser.h" -- 1.7.3 |
From: Miquel G. <gbm...@gm...> - 2010-11-04 23:08:05
|
New patch series to recover opj2dat command line utility. First, remove the no longer needed "logging.hpp". Miquel --- logging.hpp | 619 ----------------------------------------------------------- 1 files changed, 0 insertions(+), 619 deletions(-) delete mode 100644 logging.hpp diff --git a/logging.hpp b/logging.hpp deleted file mode 100644 index 42456c1..0000000 --- a/logging.hpp +++ /dev/null @@ -1,619 +0,0 @@ -// Boost general library logging.hpp header file ---------------------------// - -// (C) Copyright Jean-Daniel Michaud 2007. Permission to copy, use, modify, -// sell and distribute this software is granted provided this copyright notice -// appears in all copies. This software is provided "as is" without express or -// implied warranty, and with no claim as to its suitability for any purpose. - -// See http://www.boost.org/LICENSE_1_0.txt for licensing. -// See http://code.google.com/p/loglite/ for library home page. - -#ifndef BOOST_LOGGING_HPP -#define BOOST_LOGGING_HPP - -#include <list> -#include <stack> -#include <string> -#include <ostream> -#include <sstream> -#include <stdio.h> -#include <algorithm> -#include <exception> -#include <boost/shared_ptr.hpp> -#include <boost/tuple/tuple.hpp> -#ifndef BOOST_CONFIG_HPP -# include <boost/config.hpp> -#endif -#if defined(BOOST_HAS_THREADS) -# include <boost/thread/thread.hpp> -# include <boost/thread/condition.hpp> -#endif // BOOST_HAS_THREADS -#include <boost/date_time/gregorian/gregorian.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/format.hpp> - -#ifndef BOOST_NO_CODE_GENERATION_FOR_LOG -#define BOOST_LOG_INIT( format ) \ -{ \ - boost::logging::logger *l = boost::logging::logger::get_instance(); \ - assert(l); \ - l->add_format(format); \ -} - -#define BOOST_LOG_ADD_OUTPUT_STREAM( sink ) \ -{ \ - boost::logging::logger *l = boost::logging::logger::get_instance(); \ - assert(l); \ - l->add_sink(sink); \ -} - -#define BOOST_LOG(level, qualifier, _trace) \ -{ \ - boost::logging::logger *l = boost::logging::logger::get_instance(); \ - assert(l); \ - if (l->get_global_max_log_level() >= level) \ - { \ - if (l->m_string_stream.str() != "") \ - l->m_string_stack.push(l->m_string_stream.str()); \ - \ - l->m_string_stream.str(""); \ - l->m_string_stream << _trace; \ - l->trace(level, qualifier, l->m_string_stream.str(), __FILE__, __LINE__); \ - if (!l->m_string_stack.empty()) \ - { \ - l->m_string_stream.str(l->m_string_stack.top()); \ - l->m_string_stack.pop(); \ - } \ - } \ -} - -#define BOOST_LOG_( level, _trace ) \ - { BOOST_LOG(level, boost::logging::log, _trace) } - -#define BOOST_LOG_UNFORMATTED(level, qualifier, _trace) \ -{ \ - boost::logging::logger *l = boost::logging::logger::get_instance(); \ - assert(l); \ - if (l->get_global_max_log_level() >= level) \ - { \ - if (l->m_string_stream.str() != "") \ - l->m_string_stack.push(l->m_string_stream.str()); \ - \ - l->m_string_stream.str(""); \ - l->m_string_stream << _trace; \ - l->unformatted_trace(level, qualifier, \ - l->m_string_stream.str(), __FILE__, __LINE__); \ - if (!l->m_string_stack.empty()) \ - { \ - l->m_string_stream.str(l->m_string_stack.top()); \ - l->m_string_stack.pop(); \ - } \ - } \ -} - -#define BOOST_LOG_FINALIZE() \ -{ \ - boost::logging::logger *l = boost::logging::logger::get_instance(); \ - assert(l); \ - l->clear(); \ -} -#else // !BOOST_NO_CODE_GENERATION_FOR_LOG -#define BOOST_LOG_INIT( format ) -#define BOOST_LOG_ADD_OUTPUT_STREAM( sink ) -#define BOOST_LOG(level, qualifier, _trace) -#define BOOST_LOG_( level, _trace ) -#define BOOST_LOG_UNFORMATTED(level, qualifier, _trace) -#endif // BOOST_NO_CODE_GENERATION_FOR_LOG - -#define BOOST_MAX_LINE_STR_SIZE 20 // log(2^64) -#define BOOST_LEVEL_UP_LIMIT 999 - -namespace boost { - - namespace logging { - -// Logging forward declarations ---------------------------------------------// - class log_element; - class level_element; - class qualifier; - class trace_element; - class format; - class sink; - class logger; - -// Logging typedefs declarations --------------------------------------------// - typedef enum { LEVEL = 0, QUALIFIER, TRACE, FILENAME, LINE } param_e; - typedef enum { SINK = 0, FORMAT } sink_format_assoc_e; - typedef std::list<boost::shared_ptr<log_element> > element_list_t; - typedef std::list<boost::shared_ptr<std::ostream> > stream_list_t; - typedef unsigned short level_t; - typedef tuple<level_t, - const qualifier *, - std::string, - std::string, - unsigned int> log_param_t; - typedef std::list<format> format_list_t; - typedef tuple<sink, format&> sink_format_assoc_t; - typedef std::list<sink_format_assoc_t> sink_format_assoc_list_t; - typedef std::list<qualifier *> qualifier_list_t; - -// Used for shared_ptr() on statically allocated log_element ----------------// - struct null_deleter - { void operator()(void const *) const {} }; - -// Qualifier class declaration ----------------------------------------------// - class qualifier - { - public: - qualifier() {} - inline std::string to_string() const { return m_identifier; } - virtual bool operator==(const qualifier &q) { return false; } - protected: - std::string m_identifier; - }; - - class log_qualifier : public qualifier - { - public: - log_qualifier() { m_identifier = "log"; } - bool operator==(const qualifier &q) - { return (dynamic_cast<const log_qualifier *>(&q) != NULL); } - }; - - class notice_qualifier : public qualifier - { - public: - notice_qualifier() { m_identifier = "notice"; } - bool operator==(const qualifier &q) - { return (dynamic_cast<const notice_qualifier *>(&q) != NULL); } - }; - - class warning_qualifier : public qualifier - { - public: - warning_qualifier() { m_identifier = "warning"; } - bool operator==(const qualifier &q) - { return (dynamic_cast<const warning_qualifier *>(&q) != NULL); } - }; - - class error_qualifier : public qualifier - { - public: - error_qualifier() { m_identifier = "error"; } - bool operator==(const qualifier &q) - { return (dynamic_cast<const error_qualifier *>(&q) != NULL); } - }; - -// Element classes declaration ---------------------------------------------// - class log_element - { - public: - virtual std::string to_string() { assert(0); return ""; }; - - virtual std::string visit(format &f, const log_param_t &log_param); - }; - - class level_element : public log_element - { - public: - std::string to_string(level_t l) - { - return str(boost::format("%i") % l); - }; - - std::string visit(format &f, const log_param_t &log_param); - }; - - class filename_element : public log_element - { - public: - std::string to_string(const std::string &f) { return f; } - std::string visit(format &f, const log_param_t &log_param); - }; - - class line_element : public log_element - { - public: - std::string to_string(unsigned int l) - { - return str(boost::format("%i") % l); - } - std::string visit(format &f, const log_param_t &log_param); - }; - - class date_element : public log_element - { - public: - std::string to_string() - { - boost::gregorian::date d(boost::gregorian::day_clock::local_day()); - return boost::gregorian::to_iso_extended_string(d); - } - }; - - class time_element : public log_element - { - public: - std::string to_string() - { - boost::posix_time::ptime - t(boost::posix_time::microsec_clock::local_time()); - return boost::posix_time::to_simple_string(t); - }; - }; - - class trace_element : public log_element - { - public: - std::string to_string(const std::string& s) { return s; }; - - std::string visit(format &f, const log_param_t &log_param); - }; - - class eol_element : public log_element - { - public: - std::string to_string() { return "\n"; }; - }; - - class literal_element : public log_element - { - public: - explicit literal_element(const std::string &l) : m_literal(l) {} - std::string to_string() { return m_literal; }; - private: - std::string m_literal; - }; - - class qualifier_element : public log_element - { - public: - qualifier_element(const qualifier &lq) - { - m_qualifier_identifier = lq.to_string(); - } - std::string to_string() { return m_qualifier_identifier; }; - private: - std::string m_qualifier_identifier; - }; - -// Format class declatation -------------------------------------------------// - class format - { - public: - format(log_element &e) - : m_identifier("unnamed") - { - boost::shared_ptr<boost::logging::log_element> p(&e, null_deleter()); - m_element_list.push_back(p); - } - - format(log_element &e, const std::string &identifier) - : m_identifier(identifier) - { - boost::shared_ptr<boost::logging::log_element> p(&e, null_deleter()); - m_element_list.push_back(p); - } - - format(element_list_t e) - : m_element_list(e), m_identifier("unnamed") {} - - format(element_list_t e, const std::string &identifier) - : m_element_list(e), m_identifier(identifier) {} - - std::string produce_trace(const log_param_t &log_param) - { - element_list_t::iterator e_it = m_element_list.begin(); - std::stringstream str_stream; - for (; e_it != m_element_list.end(); ++e_it) - { - str_stream << (*e_it)->visit(*this, log_param); - } - - return str_stream.str(); - } - - // Visitors for the log elements - std::string accept(log_element &e) - { - return e.to_string(); - } - std::string accept(level_element &e, level_t l) - { - return e.to_string(l); - } - std::string accept(trace_element &e, const std::string& s) - { - return e.to_string(s); - } - std::string accept(filename_element &e, const std::string& s) - { - return e.to_string(s); - } - std::string accept(line_element &e, unsigned int l) - { - return e.to_string(l); - } - - private: - element_list_t m_element_list; - std::string m_identifier; - }; - -// Sink class declaration ---------------------------------------------------// - class sink - { - public: - sink(std::ostream *s, level_t max_log_level = 1) - { - if (s) - if (*s == std::cout || *s == std::cerr || *s == std::clog) - m_output_stream.reset(s, null_deleter()); - else - m_output_stream.reset(s); - - set_max_log_level(max_log_level); - } - - void set_max_log_level(level_t max_log_level) - { - m_max_log_level = ((BOOST_LEVEL_UP_LIMIT < max_log_level) - ? BOOST_LEVEL_UP_LIMIT : max_log_level); - } - - inline level_t get_max_log_level() const { return m_max_log_level; } - - void consume_trace(format &f, const log_param_t &log_param) - { - /* make here check to avoid producing a useless trace */ - if (get<LEVEL>(log_param) > m_max_log_level) - return ; - - qualifier_list_t::const_iterator it = m_qualifier_list.begin(); - bool qualifier_present = false; - for ( ; !qualifier_present && it != m_qualifier_list.end(); ++it) - qualifier_present = (**it == *get<QUALIFIER>(log_param)); - - if (!qualifier_present) - return ; - - *m_output_stream << f.produce_trace(log_param); - } - - void attach_qualifier(qualifier &q) - { - m_qualifier_list.push_back(&q); - } - - private: - level_t m_max_log_level; - shared_ptr<std::ostream> m_output_stream; - qualifier_list_t m_qualifier_list; - }; - -// Element static instantiations --------------------------------------------// - static level_element level = level_element(); - static filename_element filename = filename_element(); - static line_element line = line_element(); - static date_element date = date_element(); - static time_element time = time_element(); - static trace_element trace = trace_element(); - static eol_element eol = eol_element(); - - static log_qualifier log = log_qualifier(); - static notice_qualifier notice = notice_qualifier(); - static warning_qualifier warning = warning_qualifier(); - static error_qualifier error = error_qualifier(); - -// Logger class declaration ------------------------------------------------// - class logger - { - public: - logger() : m_global_max_log_level(0) {} - - void clear() - { - m_format_list.clear(); - m_sink_format_assoc.clear(); - } - - static logger *get_instance() - { -#if defined(BOOST_HAS_THREADS) - static boost::mutex m_inst_mutex; - boost::mutex::scoped_lock scoped_lock(m_inst_mutex); -#endif // BOOST_HAS_THREADS - static logger *l = NULL; - - if (!l) - { - l = new logger(); - static shared_ptr<logger> s_ptr_l(l); - } - - return l; - } - - void add_format(const format &f) - { - m_format_list.push_back(f); - } - - void add_sink(const sink &s) - { - if (m_format_list.begin() == m_format_list.end()) - throw "no format defined"; - - // Updating global_max_level used for full lazy evaluation - m_global_max_log_level = - (m_global_max_log_level < s.get_max_log_level()) - ? - s.get_max_log_level() - : - m_global_max_log_level; - - m_sink_format_assoc.push_back - ( - sink_format_assoc_t(s, *m_format_list.begin()) - ); - } - - void add_sink(const sink &s, format &f) - { - // Updating global_max_level used for full lazy evaluation - m_global_max_log_level = - (m_global_max_log_level < s.get_max_log_level()) - ? - s.get_max_log_level() - : - m_global_max_log_level; - - m_sink_format_assoc.push_back(sink_format_assoc_t(s, f)); - } - - inline level_t get_global_max_log_level() - { return m_global_max_log_level; } - - void trace(unsigned short l, - const qualifier &q, - const std::string &t, - const std::string &f, - unsigned int ln) - { -#if defined(BOOST_HAS_THREADS) - boost::mutex::scoped_lock scoped_lock(m_mutex); -#endif // BOOST_HAS_THREADS - - log_param_t log_param(l, &q, t, f, ln); - sink_format_assoc_list_t::iterator - s_it = m_sink_format_assoc.begin(); - for (; s_it != m_sink_format_assoc.end(); ++s_it) - { - get<SINK>(*s_it).consume_trace(get<FORMAT>(*s_it), log_param); - } - } - - void unformatted_trace(unsigned short l, - const qualifier &q, - const std::string &t, - const std::string &f, - unsigned int ln); - - public: - std::stringstream m_string_stream; - std::stack<std::string> m_string_stack; - - private: - format_list_t m_format_list; - sink_format_assoc_list_t m_sink_format_assoc; - - // The global max log level is the highest log level on all the link - // added to the logger. If no sink as a log level high enougth for - // a trace, the trace does not need to be evaluated. - level_t m_global_max_log_level; -#if defined(BOOST_HAS_THREADS) - boost::mutex m_mutex; -#endif // BOOST_HAS_THREADS - }; // logger - -// Element functions definition ---------------------------------------------// - inline std::string log_element::visit(format &f, - const log_param_t &log_param) - { - return f.accept(*this); - } - - inline std::string level_element::visit(format &f, - const log_param_t &log_param) - { - return f.accept(*this, get<LEVEL>(log_param)); - } - - inline std::string trace_element::visit(format &f, - const log_param_t &log_param) - { - return f.accept(*this, get<TRACE>(log_param)); - } - - inline std::string filename_element::visit(format &f, - const log_param_t &log_param) - { - return f.accept(*this, get<FILENAME>(log_param)); - } - - inline std::string line_element::visit(format &f, - const log_param_t &log_param) - { - return f.accept(*this, get<LINE>(log_param)); - } - - } // !namespace logging - -} // !namespace boost - -// Element global operators -------------------------------------------------// -inline boost::logging::element_list_t operator>>( - boost::logging::log_element &lhs, - boost::logging::log_element &rhs) -{ - boost::logging::element_list_t l; - l.push_back(boost::shared_ptr<boost::logging::log_element> - (&lhs, boost::logging::null_deleter())); - l.push_back(boost::shared_ptr<boost::logging::log_element> - (&rhs, boost::logging::null_deleter())); - return l; -} - -inline boost::logging::element_list_t operator>>( - boost::logging::element_list_t lhs, - boost::logging::log_element &rhs) -{ - lhs.push_back(boost::shared_ptr<boost::logging::log_element> - (&rhs, boost::logging::null_deleter())); - return lhs; -} - -inline boost::logging::element_list_t operator>>( - const std::string &s, - boost::logging::log_element &rhs) -{ - boost::logging::element_list_t l; - boost::shared_ptr<boost::logging::literal_element> - p(new boost::logging::literal_element(s)); - l.push_back(p); - l.push_back(boost::shared_ptr<boost::logging::log_element> - (&rhs, boost::logging::null_deleter())); - return l; -} - -inline boost::logging::element_list_t operator>>( - boost::logging::element_list_t lhs, - const std::string &s) -{ - boost::shared_ptr<boost::logging::literal_element> - p(new boost::logging::literal_element(s)); - lhs.push_back(p); - return lhs; -} - -inline -void boost::logging::logger::unformatted_trace(unsigned short l, - const qualifier &q, - const std::string &t, - const std::string &f, - unsigned int ln) -{ -#if defined(BOOST_HAS_THREADS) - boost::mutex::scoped_lock scoped_lock(m_mutex); -#endif // BOOST_HAS_THREADS - log_param_t log_param(l, &q, t, f, ln); - sink_format_assoc_list_t::iterator - s_it = m_sink_format_assoc.begin(); - for (; s_it != m_sink_format_assoc.end(); ++s_it) - { - boost::logging::format f(boost::logging::trace); - get<SINK>(*s_it).consume_trace(f, log_param); - } -} - -#endif // !BOOST_LOGGING_HPP -- 1.7.3 |
From: Knut F. <Knu...@gm...> - 2010-11-03 21:25:10
|
[2010-11-03 13:38] Miquel Garriga <gbm...@gm...>: > What I dislike of CMake is: > a) There is no easy way of removing the CMake generated files (like > "make distclean" > does for qmake), other that creating a "build" subdir and start cmake > from there. Yes, that would be the preferred solution with CMake (for good reasons, I'd say[1]). > That solution is (almost equivalent) to use a subdir for opj2dat. Why? Subdirs aren't evil if used with some consideration. I wouldn't even say a subdir for opj2dat would be totally out of the question, although a subdir for a single source file is a bit suboptimal due to the (mental) overhead it creates. Having a separate directory for output files makes perfect sense to me, also since this keeps the source directory free from non-source files (and thus easier to understand) at all times. Besides, if you insist on in-source builds, you can use Git to determine which files were added (e.g. using "git status -s") and possibly even write a small script which removes them. > b) There is no easy way to see what the make command will do. > The usual "make -n" command only shows a series of CMake related > commands. Admittedly the "make -n" output with CMake isn't as nice as with qmake, but it shows not *only* CMake-related commands (at least on my system). A small script munging the "make -n" output a bit may help. Try something like make -n | awk '/cmake_echo|cmake_progress/ {next} /cmake_link_script/ {getline < $4} //' > Maybe in the long run handmade Makefile(s) will be the simplest > solution. I hope not. Having to maintain separate Makefiles for all sorts of different platforms is annoying and error-prone. By the way, we already did have this approach in liborigin1 (last commit was dba976c); not suprprisingly, the implemented functionality varied widely between the relatively complete Linux Makefile (with lots of settings, install and uninstall targets) and the Solaris one (which only supported rudimentary opj2dat and clean targets). With a cross- platform build tool, all platforms get the same set of features. Not to mention none gets outdated, e.g. if the set of source files changes. Just to be clear on this point, I don't think CMake is anywhere near perfect (although I have different gripes with it than you). I just think it's the least undesirable of the available options. Knut [1] http://www.cmake.org/Wiki/CMake_FAQ#CMake_does_not_generate_a_.22make_distclean.22_target._Why.3F |
From: Miquel G. <gbm...@gm...> - 2010-11-03 12:38:27
|
2010/11/2 Knut Franke <Knu...@gm...>: > That's not exactly what the readme says. Is there a reason for the "make > clean" step? At least on Linux/GCC, it doesn't seem to make a difference > whether the files are compiled with "make" or "make staticlib"; but that might > be different on other platforms... That's the only reason. Other platforms may need the "make clean" step. > I don't see a big problem with depending on CMake (whether LabPlot/SciDAVis > depend on it or not), given that it's the build system of choice for KDE4 and > thus available virtually everywhere. Also, while my above point was invalid, > there's still the issue with the somewhat unintuitive build process for > opj2dat. Maybe that patch could include at least a suitable note in the > readme... What I dislike of CMake is: a) There is no easy way of removing the CMake generated files (like "make distclean" does for qmake), other that creating a "build" subdir and start cmake from there. That solution is (almost equivalent) to use a subdir for opj2dat. b) There is no easy way to see what the make command will do. The usual "make -n" command only shows a series of CMake related commands. Maybe in the long run handmade Makefile(s) will be the simplest solution. > If we do that, I'd suggest replacing >> +QT -= core gui > with > +CONFIG -= qt > which removes even more Qt-specific stuff. OK. > > Knut > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > Liborigin-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/liborigin-devel > |
From: Knut F. <Knu...@gm...> - 2010-11-02 07:38:31
|
[2010-11-01 18:55] Miquel Garriga <gbm...@gm...>: > 2010/11/1 Knut Franke <Knu...@gm...>: [...] > > As far as I can see, qmake can build either a static or a dynamic > > library, but not both at the same time. Adding just this installation > > target will install whatever liborigin2.a happens to be lieing around > > from the last time qmake;make was run with CONFIG+=staticlib enabled, > > which is not a good idea IMHO. > > Not exactly, if you follow the instructions in README. The command > "qmake liborigin2.pro" > (i.e. without CONFIG+=staticlib enabled) produces a Makefile with both > a (default) dynamic library target and also a static library target. Looks like I should have RTFM ;-). > Therefore, the following commands > qmake liborigin2.pro; make; make clean; make staticlib; make install > should compile and install both libraries. That's not exactly what the readme says. Is there a reason for the "make clean" step? At least on Linux/GCC, it doesn't seem to make a difference whether the files are compiled with "make" or "make staticlib"; but that might be different on other platforms... > > Instead of trying to work around the various shortcomings of qmake, I'd > > suggest resurrecting CMakeLists.txt from commit f19437 (with a suitably > > updated VERSION). This is also a much smaller dependency than Qt > > (assuming someone wants to use liborigin in a non-Qt context), and > > LabPlot2 / future SciDAVis will most likely be using CMake anyway. > > I would prefer to wait for that change until at least LabPlot2 or > SciDAVis do change > to CMake. After all, the best use of liborigin2 capabilities is still > done with qmake driven applications. I don't see a big problem with depending on CMake (whether LabPlot/SciDAVis depend on it or not), given that it's the build system of choice for KDE4 and thus available virtually everywhere. Also, while my above point was invalid, there's still the issue with the somewhat unintuitive build process for opj2dat. Maybe that patch could include at least a suitable note in the readme... > Another possibility would be to > keep both (qmake and CMake) building > scripts. I suspect that would add more confusion than it's worth, given that the point of using CMake is to simplify the build process. I'd rather stick with qmake (for now) than trying to maintain both scripts. If we do that, I'd suggest replacing > +QT -= core gui with +CONFIG -= qt which removes even more Qt-specific stuff. Knut |
From: Miquel G. <gbm...@gm...> - 2010-11-01 17:55:09
|
2010/11/1 Knut Franke <Knu...@gm...>: > [ Sorry for not replying properly; I managed to screw up my first subscription > attempt and didn't receive the first three mails. ] > >> +targeta.path = $$INSTALLBASE/lib/liborigin2 > [...] >> +targeta.files = liborigin2.a > > As far as I can see, qmake can build either a static or a dynamic library, but > not both at the same time. Adding just this installation target will install > whatever liborigin2.a happens to be lieing around from the last time > qmake;make was run with CONFIG+=staticlib enabled, which is not a good idea > IMHO. Not exactly, if you follow the instructions in README. The command "qmake liborigin2.pro" (i.e. without CONFIG+=staticlib enabled) produces a Makefile with both a (default) dynamic library target and also a static library target. Therefore, the following commands qmake liborigin2.pro; make; make clean; make staticlib; make install should compile and install both libraries. > Instead of trying to work around the various shortcomings of qmake, I'd > suggest resurrecting CMakeLists.txt from commit f19437 (with a suitably > updated VERSION). This is also a much smaller dependency than Qt (assuming > someone wants to use liborigin in a non-Qt context), and LabPlot2 / future > SciDAVis will most likely be using CMake anyway. I would prefer to wait for that change until at least LabPlot2 or SciDAVis do change to CMake. After all, the best use of liborigin2 capabilities is still done with qmake driven applications. Another possibility would be to keep both (qmake and CMake) building scripts. Miquel |