98 lines
2.7 KiB
Plaintext
98 lines
2.7 KiB
Plaintext
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
//as published by the Free Software Foundation.
|
|
|
|
#ifndef OSGDB_OUTPUT
|
|
#define OSGDB_OUTPUT 1
|
|
|
|
#include <osg/Object>
|
|
|
|
#include <osgDB/Export>
|
|
|
|
#include <string>
|
|
#include <map>
|
|
|
|
#include <fstream>
|
|
|
|
namespace osgDB {
|
|
|
|
/** ofstream wrapper class for adding support for indenting.
|
|
Used in output of .osg ASCII files to improve their readability.*/
|
|
class OSGDB_EXPORT Output : public std::ofstream
|
|
{
|
|
public:
|
|
|
|
Output();
|
|
Output(const char* name);
|
|
|
|
virtual ~Output();
|
|
|
|
void open(const char *name);
|
|
|
|
// comment out temporarily to avoid compilation problems, RO Jan 2002.
|
|
// void open(const char *name,int mode);
|
|
|
|
Output& indent();
|
|
|
|
/** wrap a string with "" quotes and use \" for any internal quotes.*/
|
|
std::string wrapString(const std::string& str);
|
|
|
|
inline void setIndentStep(int step) { _indentStep = step; }
|
|
inline int getIndentStep() const { return _indentStep; }
|
|
|
|
inline void setIndent(int indent) { _indent = indent; }
|
|
inline int getIndent() const { return _indent; }
|
|
|
|
inline void setNumIndicesPerLine(int num) { _numIndicesPerLine = num; }
|
|
inline int getNumIndicesPerLine() const { return _numIndicesPerLine; }
|
|
|
|
void moveIn();
|
|
void moveOut();
|
|
|
|
virtual bool writeObject(const osg::Object& obj);
|
|
|
|
|
|
bool getUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
|
|
bool createUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
|
|
bool registerUniqueIDForObject(const osg::Object* obj,std::string& uniqueID);
|
|
|
|
enum PathNameHint
|
|
{
|
|
AS_IS,
|
|
FULL_PATH,
|
|
RELATIVE_PATH,
|
|
FILENAME_ONLY
|
|
};
|
|
|
|
inline void setPathNameHint(const PathNameHint pnh) { _pathNameHint = pnh; }
|
|
inline const PathNameHint getPathNameHint() const { return _pathNameHint; }
|
|
|
|
virtual const std::string getFileNameForOutput(const std::string& filename) const;
|
|
|
|
|
|
protected:
|
|
|
|
// prevent copy construction and assignment.
|
|
Output(const Output&);
|
|
Output& operator = (const Output&);
|
|
|
|
virtual void init();
|
|
|
|
int _indent;
|
|
int _indentStep;
|
|
|
|
int _numIndicesPerLine;
|
|
|
|
typedef std::map<const osg::Object*,std::string> UniqueIDToLabelMapping;
|
|
UniqueIDToLabelMapping _objectToUniqueIDMap;
|
|
|
|
std::string _filename;
|
|
|
|
PathNameHint _pathNameHint;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // __SG_OUTPUT_H
|