Moved osgIntrospection across to standard OSG coding style.
This commit is contained in:
@@ -56,16 +56,16 @@ namespace osgIntrospection
|
||||
};
|
||||
|
||||
/// Writes a textual representation of the value's content to a stream.
|
||||
virtual std::ostream &writeTextValue(std::ostream &, const Value &v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::TEXT_WRITE, v.getType().getStdTypeInfo()); }
|
||||
virtual std::ostream &writeTextValue(std::ostream &, const Value& v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::TEXT_WRITE, v.getType().getStdTypeInfo()); }
|
||||
|
||||
/// Reads a textual representation of the value's content from a stream.
|
||||
virtual std::istream &readTextValue(std::istream &, Value &v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::TEXT_READ, v.getType().getStdTypeInfo()); }
|
||||
virtual std::istream &readTextValue(std::istream &, Value& v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::TEXT_READ, v.getType().getStdTypeInfo()); }
|
||||
|
||||
/// Writes a binary representation of the value's content to a stream.
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &, const Value &v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::BINARY_WRITE, v.getType().getStdTypeInfo()); }
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &, const Value& v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::BINARY_WRITE, v.getType().getStdTypeInfo()); }
|
||||
|
||||
/// Reads a binary representation of the value's content from a stream.
|
||||
virtual std::istream &readBinaryValue(std::istream &, Value &v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::BINARY_READ, v.getType().getStdTypeInfo()); }
|
||||
virtual std::istream &readBinaryValue(std::istream &, Value& v, const Options* = 0) const { throw StreamingNotSupportedException(StreamingNotSupportedException::BINARY_READ, v.getType().getStdTypeInfo()); }
|
||||
|
||||
/// Virtual destructor.
|
||||
virtual ~ReaderWriter() {}
|
||||
@@ -83,23 +83,23 @@ namespace osgIntrospection
|
||||
class StdReaderWriter: public ReaderWriter
|
||||
{
|
||||
public:
|
||||
virtual std::ostream &writeTextValue(std::ostream &os, const Value &v, const Options * = 0) const
|
||||
virtual std::ostream &writeTextValue(std::ostream &os, const Value& v, const Options * = 0) const
|
||||
{
|
||||
return (os << variant_cast<T>(v));
|
||||
}
|
||||
|
||||
virtual std::istream &readTextValue(std::istream &is, Value &v, const Options * = 0) const
|
||||
virtual std::istream &readTextValue(std::istream &is, Value& v, const Options * = 0) const
|
||||
{
|
||||
if (v.isEmpty()) v = Value(T());
|
||||
return (is >> variant_cast<T &>(v));
|
||||
}
|
||||
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &os, const Value &v, const Options * = 0) const
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &os, const Value& v, const Options * = 0) const
|
||||
{
|
||||
return os.write(reinterpret_cast<const char *>(extract_raw_data<T>(v)), sizeof(T));
|
||||
}
|
||||
|
||||
virtual std::istream &readBinaryValue(std::istream &is, Value &v, const Options * = 0) const
|
||||
virtual std::istream &readBinaryValue(std::istream &is, Value& v, const Options * = 0) const
|
||||
{
|
||||
if (v.isEmpty()) v = Value(T());
|
||||
return is.read(reinterpret_cast<char *>(extract_raw_data<T>(v)), sizeof(T));
|
||||
@@ -114,14 +114,14 @@ namespace osgIntrospection
|
||||
template<typename T>
|
||||
class EnumReaderWriter: public ReaderWriter
|
||||
{
|
||||
virtual std::ostream &writeTextValue(std::ostream &os, const Value &v, const Options *options = 0) const
|
||||
virtual std::ostream &writeTextValue(std::ostream &os, const Value& v, const Options *options = 0) const
|
||||
{
|
||||
int numeric = static_cast<int>(variant_cast<T>(v));
|
||||
|
||||
if (!options || !options->getForceNumericOutput())
|
||||
{
|
||||
const Type &type = v.getType();
|
||||
const EnumLabelMap &elm = type.getEnumLabels();
|
||||
const Type& type = v.getType();
|
||||
const EnumLabelMap& elm = type.getEnumLabels();
|
||||
EnumLabelMap::const_iterator i = elm.find(numeric);
|
||||
if (i != elm.end())
|
||||
{
|
||||
@@ -158,7 +158,7 @@ namespace osgIntrospection
|
||||
return os << numeric;
|
||||
}
|
||||
|
||||
virtual std::istream &readTextValue(std::istream &is, Value &v, const Options * = 0) const
|
||||
virtual std::istream &readTextValue(std::istream &is, Value& v, const Options * = 0) const
|
||||
{
|
||||
if (v.isEmpty()) v = Value(T());
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace osgIntrospection
|
||||
std::string s;
|
||||
if (is >> s)
|
||||
{
|
||||
const Type &type = v.getType();
|
||||
const EnumLabelMap &elm = type.getEnumLabels();
|
||||
const Type& type = v.getType();
|
||||
const EnumLabelMap& elm = type.getEnumLabels();
|
||||
for (EnumLabelMap::const_iterator i=elm.begin(); i!=elm.end(); ++i)
|
||||
{
|
||||
if (i->second.compare(s) == 0)
|
||||
@@ -189,12 +189,12 @@ namespace osgIntrospection
|
||||
return is;
|
||||
}
|
||||
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &os, const Value &v, const Options * = 0) const
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &os, const Value& v, const Options * = 0) const
|
||||
{
|
||||
return os.write(reinterpret_cast<const char *>(extract_raw_data<T>(v)), sizeof(T));
|
||||
}
|
||||
|
||||
virtual std::istream &readBinaryValue(std::istream &is, Value &v, const Options * = 0) const
|
||||
virtual std::istream &readBinaryValue(std::istream &is, Value& v, const Options * = 0) const
|
||||
{
|
||||
if (v.isEmpty())
|
||||
v = Value(T());
|
||||
@@ -209,12 +209,12 @@ namespace osgIntrospection
|
||||
class PtrReaderWriter: public ReaderWriter
|
||||
{
|
||||
public:
|
||||
virtual std::ostream &writeTextValue(std::ostream &os, const Value &v, const Options* = 0) const
|
||||
virtual std::ostream &writeTextValue(std::ostream &os, const Value& v, const Options* = 0) const
|
||||
{
|
||||
return (os << (void*)variant_cast<T>(v));
|
||||
}
|
||||
|
||||
virtual std::istream &readTextValue(std::istream &is, Value &v, const Options* = 0) const
|
||||
virtual std::istream &readTextValue(std::istream &is, Value& v, const Options* = 0) const
|
||||
{
|
||||
void *ptr;
|
||||
is >> ptr;
|
||||
@@ -222,12 +222,12 @@ namespace osgIntrospection
|
||||
return is;
|
||||
}
|
||||
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &os, const Value &v, const Options* = 0) const
|
||||
virtual std::ostream &writeBinaryValue(std::ostream &os, const Value& v, const Options* = 0) const
|
||||
{
|
||||
return os.write(reinterpret_cast<const char *>(extract_raw_data<T>(v)), sizeof(T));
|
||||
}
|
||||
|
||||
virtual std::istream &readBinaryValue(std::istream &is, Value &v, const Options* = 0) const
|
||||
virtual std::istream &readBinaryValue(std::istream &is, Value& v, const Options* = 0) const
|
||||
{
|
||||
T ptr;
|
||||
is.read(reinterpret_cast<char *>(&ptr), sizeof(T));
|
||||
|
||||
Reference in New Issue
Block a user