vsg  1.1.0
VulkanSceneGraph library
VSG.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2018 Robert Osfield
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 
13 </editor-fold> */
14 
15 #include <vsg/io/ReaderWriter.h>
16 
17 #include <sstream>
18 
19 namespace vsg
20 {
21 
23  class VSG_DECLSPEC VSG : public Inherit<ReaderWriter, VSG>
24  {
25  public:
26  VSG();
27 
28  vsg::ref_ptr<vsg::Object> read(const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
29  vsg::ref_ptr<vsg::Object> read(std::istream& fin, vsg::ref_ptr<const vsg::Options> options = {}) const override;
30  vsg::ref_ptr<vsg::Object> read(const uint8_t* ptr, size_t size, vsg::ref_ptr<const vsg::Options> = {}) const override;
31 
32  bool write(const vsg::Object* object, const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
33  bool write(const vsg::Object* object, std::ostream& fout, vsg::ref_ptr<const vsg::Options> options = {}) const override;
34 
35  bool getFeatures(Features& features) const override;
36 
37  ObjectFactory* getObjectFactory() { return _objectFactory; }
38  const ObjectFactory* getObjectFactory() const { return _objectFactory; }
39 
40  enum FormatType
41  {
42  BINARY,
43  ASCII,
44  NOT_RECOGNIZED
45  };
46 
47  using FormatInfo = std::pair<FormatType, VsgVersion>;
48 
49  FormatInfo readHeader(std::istream& fin) const;
50  void writeHeader(std::ostream& fout, const FormatInfo& formatInfo) const;
51 
52  protected:
53  ref_ptr<ObjectFactory> _objectFactory;
54  };
55  VSG_type_name(vsg::VSG);
56 
57 } // namespace vsg
Definition: Inherit.h:28
Definition: ObjectFactory.h:27
Definition: Object.h:42
Definition: Path.h:32
ReaderWriter for reading and writing native VSG ascii and binary files.
Definition: VSG.h:24
vsg::ref_ptr< vsg::Object > read(const uint8_t *ptr, size_t size, vsg::ref_ptr< const vsg::Options >={}) const override
read object from memory block, return object on success, return null ref_ptr<> if format not supporte...
vsg::ref_ptr< vsg::Object > read(std::istream &fin, vsg::ref_ptr< const vsg::Options > options={}) const override
read object from input stream, return object on success, return null ref_ptr<> if format not supporte...
bool write(const vsg::Object *object, const vsg::Path &filename, vsg::ref_ptr< const vsg::Options > options={}) const override
write object to file, return true on success, return false on failure.
vsg::ref_ptr< vsg::Object > read(const vsg::Path &filename, vsg::ref_ptr< const vsg::Options > options={}) const override
read object from file, return object on success, return null ref_ptr<> if format not supported,...
bool write(const vsg::Object *object, std::ostream &fout, vsg::ref_ptr< const vsg::Options > options={}) const override
write object to output stream, return true on success, return false on failure.
bool getFeatures(Features &features) const override
get the Features supported by this ReaderWriter
Definition: ReaderWriter.h:92