vsg  1.1.0
VulkanSceneGraph library
read.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 <istream>
16 #include <vsg/core/Inherit.h>
17 #include <vsg/io/FileSystem.h>
18 #include <vsg/io/Options.h>
19 
20 namespace vsg
21 {
22 
24  extern VSG_DECLSPEC ref_ptr<Object> read(const Path& filename, ref_ptr<const Options> options = {});
25 
27  extern VSG_DECLSPEC PathObjects read(const Paths& filenames, ref_ptr<const Options> options = {});
28 
30  extern VSG_DECLSPEC ref_ptr<Object> read(std::istream& fin, ref_ptr<const Options> options = {});
31 
33  extern VSG_DECLSPEC ref_ptr<Object> read(const uint8_t* ptr, size_t size, ref_ptr<const Options> options = {});
34 
36  template<class T>
37  ref_ptr<T> read_cast(const Path& filename, ref_ptr<const Options> options = {})
38  {
39  auto object = read(filename, options);
40  return vsg::ref_ptr<T>(dynamic_cast<T*>(object.get()));
41  }
42 
44  template<class T>
45  ref_ptr<T> read_cast(std::istream& fin, ref_ptr<const Options> options = {})
46  {
47  auto object = read(fin, options);
48  return vsg::ref_ptr<T>(dynamic_cast<T*>(object.get()));
49  }
50 
52  template<class T>
53  ref_ptr<T> read_cast(const uint8_t* ptr, size_t size, ref_ptr<const Options> options = {})
54  {
55  auto object = read(ptr, size, options);
56  return vsg::ref_ptr<T>(dynamic_cast<T*>(object.get()));
57  }
58 
59 } // namespace vsg
Definition: ref_ptr.h:22