From Philipp Siemoleit,

There are some group codes (i.e. "62") which are interpreted as
    dxfDataType::SHORT. That's right because the dxf-specification defines
    "16 bit integer" as the type for the corresponding value.
    But readerBase::readGroup() calls readValue(std::ifstream&, unsigned
    short). I changed readValue(std::ifstream&, unsigned short) to
    readValue(std::ifstream&, short). I found no group code at the dxf-specs
    which needs a "16 bit unsigned integer" value. So the
    readValue(std::ifstream&, unsigned short) function is obsolete - right?
This commit is contained in:
Robert Osfield
2006-06-26 09:30:16 +00:00
parent a9f2e345c9
commit 3b499341ed
3 changed files with 62 additions and 62 deletions

View File

@@ -22,27 +22,27 @@
/// associated with it).
class codeValue {
public:
codeValue() { reset(); }
void reset()
{
_groupCode = -100;
_type = 0;
_bool = false;
_short = 0;
_int = 0;
_long = 0;
_double = 0;
_string = "";
}
int _groupCode;
int _type;
std::string _unknown;
std::string _string;
bool _bool;
unsigned short _short;
int _int;
long _long;
double _double;
codeValue() { reset(); }
void reset()
{
_groupCode = -100;
_type = 0;
_bool = false;
_short = 0;
_int = 0;
_long = 0;
_double = 0;
_string = "";
}
int _groupCode;
int _type;
std::string _unknown;
std::string _string;
bool _bool;
short _short;
int _int;
long _long;
double _double;
};
typedef std::vector<codeValue> VariableList; // this may be too big, find another way

View File

@@ -124,11 +124,11 @@ bool readerText::readValue(std::ifstream& f, bool &b)
return false;
}
}
bool readerText::readValue(std::ifstream& f, unsigned short &s)
bool readerText::readValue(std::ifstream& f, short &s)
{
if (getTrimmedLine(f)) {
_str >> s;
return success(!_str.fail(), "unsigned short");
return success(!_str.fail(), "short");
} else {
return false;
}

View File

@@ -31,41 +31,41 @@ class codeValue;
class readerBase :public osg::Referenced
{
public:
readerBase() {}
virtual ~readerBase() {}
bool readGroup(std::ifstream& f, codeValue& cv);
readerBase() {}
virtual ~readerBase() {}
bool readGroup(std::ifstream& f, codeValue& cv);
protected:
virtual bool readGroupCode(std::ifstream& f, int &groupcode) = 0;
virtual bool readValue(std::ifstream& f, std::string &s) = 0;
virtual bool readValue(std::ifstream& f, bool &b) = 0;
virtual bool readValue(std::ifstream& f, unsigned short &s) = 0;
virtual bool readValue(std::ifstream& f, int &i) = 0;
virtual bool readValue(std::ifstream& f, long &l) = 0;
virtual bool readValue(std::ifstream& f, double &d) = 0;
virtual bool readGroupCode(std::ifstream& f, int &groupcode) = 0;
virtual bool readValue(std::ifstream& f, std::string &s) = 0;
virtual bool readValue(std::ifstream& f, bool &b) = 0;
virtual bool readValue(std::ifstream& f, short &s) = 0;
virtual bool readValue(std::ifstream& f, int &i) = 0;
virtual bool readValue(std::ifstream& f, long &l) = 0;
virtual bool readValue(std::ifstream& f, double &d) = 0;
};
/// readerText. convert data using stringstream.
class readerText : public readerBase
{
public:
readerText(char delim = '\n') : readerBase(), _lineCount(0), _delim(delim) {}
virtual ~readerText() {}
readerText(char delim = '\n') : readerBase(), _lineCount(0), _delim(delim) {}
virtual ~readerText() {}
protected:
bool success(bool inSuccess, std::string type);
bool getTrimmedLine(std::ifstream& f);
bool success(bool inSuccess, std::string type);
bool getTrimmedLine(std::ifstream& f);
virtual bool readGroupCode(std::ifstream& f, int &groupcode);
virtual bool readValue(std::ifstream& f, std::string &s);
virtual bool readValue(std::ifstream& f, bool &b);
virtual bool readValue(std::ifstream& f, unsigned short &s);
virtual bool readValue(std::ifstream& f, int &i);
virtual bool readValue(std::ifstream& f, long &l);
virtual bool readValue(std::ifstream& f, double &d);
std::stringstream _str;
unsigned long _lineCount;
char _delim;
virtual bool readGroupCode(std::ifstream& f, int &groupcode);
virtual bool readValue(std::ifstream& f, std::string &s);
virtual bool readValue(std::ifstream& f, bool &b);
virtual bool readValue(std::ifstream& f, short &s);
virtual bool readValue(std::ifstream& f, int &i);
virtual bool readValue(std::ifstream& f, long &l);
virtual bool readValue(std::ifstream& f, double &d);
std::stringstream _str;
unsigned long _lineCount;
char _delim;
};
@@ -73,16 +73,16 @@ protected:
class readerBinary : public readerBase
{
public:
readerBinary() : readerBase() {}
virtual ~readerBinary() {}
readerBinary() : readerBase() {}
virtual ~readerBinary() {}
protected:
virtual bool readGroupCode(std::ifstream& /*f*/, int& /*groupcode*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, std::string& /*s*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, bool& /*b*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, unsigned short& /*s*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, int& /*i*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, long& /*l*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, double& /*d*/) { return false; }
virtual bool readGroupCode(std::ifstream& /*f*/, int& /*groupcode*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, std::string& /*s*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, bool& /*b*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, short& /*s*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, int& /*i*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, long& /*l*/) { return false; }
virtual bool readValue(std::ifstream& /*f*/, double& /*d*/) { return false; }
};
/// dxfReader. gets you through the dxf file, one group code/value pair at a time.
@@ -90,13 +90,13 @@ protected:
class dxfReader : public osg::Referenced
{
public:
dxfReader() {}
virtual ~dxfReader() {}
bool openFile(std::string fileName);
bool nextGroupCode(codeValue& cv);
dxfReader() {}
virtual ~dxfReader() {}
bool openFile(std::string fileName);
bool nextGroupCode(codeValue& cv);
protected:
std::ifstream _ifs;
osg::ref_ptr<readerBase> _reader;
std::ifstream _ifs;
osg::ref_ptr<readerBase> _reader;
};
#endif