scene_format_text.h
1 #ifndef SCENE_FORMAT_TEXT_H
2 #define SCENE_FORMAT_TEXT_H
3 
4 #include "io/resource_loader.h"
5 #include "io/resource_saver.h"
6 #include "os/file_access.h"
7 #include "scene/resources/packed_scene.h"
8 #include "variant_parser.h"
9 
10 
11 
13 
14  String local_path;
15  String res_path;
16  String error_text;
17 
18  FileAccess *f;
19 
21 
22  struct ExtResource {
23  String path;
24  String type;
25  };
26 
27 
28  bool is_scene;
29  String res_type;
30 
31  bool ignore_resource_parsing;
32 
33 // Map<String,String> remaps;
34 
35  Map<int,ExtResource> ext_resources;
36 
37  int resources_total;
38  int resource_current;
39  String resource_type;
40 
41  VariantParser::Tag next_tag;
42 
43  mutable int lines;
44 
45  Map<String,String> remaps;
46  //void _printerr();
47 
48  static Error _parse_sub_resources(void* p_self, VariantParser::Stream* p_stream,Ref<Resource>& r_res,int &line,String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText*>(p_self)->_parse_sub_resource(p_stream,r_res,line,r_err_str); }
49  static Error _parse_ext_resources(void* p_self, VariantParser::Stream* p_stream,Ref<Resource>& r_res,int &line,String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText*>(p_self)->_parse_ext_resource(p_stream,r_res,line,r_err_str); }
50 
51  Error _parse_sub_resource(VariantParser::Stream* p_stream,Ref<Resource>& r_res,int &line,String &r_err_str);
52  Error _parse_ext_resource(VariantParser::Stream* p_stream,Ref<Resource>& r_res,int &line,String &r_err_str);
53 
55 
56 
57  Ref<PackedScene> packed_scene;
58 
59 
60 friend class ResourceFormatLoaderText;
61 
62  List<RES> resource_cache;
63  Error error;
64 
65  RES resource;
66 
67 public:
68 
69  virtual void set_local_path(const String& p_local_path);
70  virtual Ref<Resource> get_resource();
71  virtual Error poll();
72  virtual int get_stage() const;
73  virtual int get_stage_count() const;
74 
75  void open(FileAccess *p_f, bool p_skip_first_tag=false);
76  String recognize(FileAccess *p_f);
77  void get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types);
78  Error rename_dependencies(FileAccess *p_f, const String &p_path,const Map<String,String>& p_map);
79 
80 
82 
83 };
84 
85 
86 
88 public:
89 
90  virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path,Error *r_error=NULL);
91  virtual void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const;
92  virtual void get_recognized_extensions(List<String> *p_extensions) const;
93  virtual bool handles_type(const String& p_type) const;
94  virtual String get_resource_type(const String &p_path) const;
95  virtual void get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types=false);
96  virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
97 
98 
99 };
100 
101 
103 
104  String local_path;
105 
106  Ref<PackedScene> packed_scene;
107 
108  bool takeover_paths;
109  bool relative_paths;
110  bool bundle_resources;
111  bool skip_editor;
112  FileAccess *f;
113  Set<RES> resource_set;
114  List<RES> saved_resources;
115  Map<RES,int> external_resources;
116  Map<RES,int> internal_resources;
117 
118  void _find_resources(const Variant& p_variant,bool p_main=false);
119 
120  static String _write_resources(void *ud,const RES& p_resource);
121  String _write_resource(const RES& res);
122 
123 
124 public:
125 
126  Error save(const String &p_path,const RES& p_resource,uint32_t p_flags=0);
127 
128 
129 };
130 
132 public:
133  static ResourceFormatSaverText* singleton;
134  virtual Error save(const String &p_path,const RES& p_resource,uint32_t p_flags=0);
135  virtual bool recognize(const RES& p_resource) const;
136  virtual void get_recognized_extensions(const RES& p_resource,List<String> *p_extensions) const;
137 
139 };
140 
141 
142 #endif // SCENE_FORMAT_TEXT_H
Definition: variant.h:74
Definition: variant_parser.h:50
Definition: variant_parser.h:11
Definition: set.h:44
Definition: scene_format_text.h:102
Definition: variant_parser.h:23
Definition: variant_parser.h:93
Definition: list.h:44
Definition: resource_loader.h:57
Definition: scene_format_text.h:12
Definition: scene_format_text.h:131
Definition: ustring.h:64
Definition: resource_saver.h:43
Definition: file_access.h:40
Definition: scene_format_text.h:87
Definition: resource_loader.h:38