GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
SourceFile.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #ifndef SOURCEFILE_H
7 #define SOURCEFILE_H
8 #include <ctime>
9 #include <memory>
10 #include "GDCore/String.h"
11 namespace gd {
12 class SerializerElement;
13 }
14 class BaseEvent;
15 
16 namespace gd {
17 
25 class GD_CORE_API SourceFile {
26  public:
27  SourceFile();
28  virtual ~SourceFile();
29 
33  SourceFile* Clone() const { return new SourceFile(*this); };
34 
38  gd::String GetFileName() const { return filename; };
39 
43  void SetFileName(gd::String filename_) { filename = filename_; };
44 
48  void SerializeTo(SerializerElement& element) const;
49 
53  void UnserializeFrom(const SerializerElement& element);
54 
59  void SetGDManaged(bool gdManaged_) { gdManaged = gdManaged_; };
60 
65  bool IsGDManaged() const { return gdManaged; };
66 
70  void SetLanguage(gd::String lang) { language = lang; }
71 
75  const gd::String& GetLanguage() const { return language; }
76 
77  private:
78  gd::String filename;
79  bool gdManaged;
81  gd::String language;
83  std::weak_ptr<BaseEvent>
84  associatedGdEvent;
88 };
89 
90 //"Tool" Functions
91 
96  : public std::
97  binary_function<std::unique_ptr<SourceFile>, gd::String, bool> {
98  bool operator()(const std::unique_ptr<SourceFile>& externalEvents,
99  gd::String name) const {
100  return externalEvents->GetFileName() == name;
101  }
102 };
103 
104 } // namespace gd
105 
106 #endif // SOURCEFILE_H
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
Represents a "physical" source file.
Definition: SourceFile.h:25
const gd::String & GetLanguage() const
Get the language of the source file.
Definition: SourceFile.h:75
void SetGDManaged(bool gdManaged_)
Set if the file is hidden from the user point of view and is only managed by GDevelop.
Definition: SourceFile.h:59
bool IsGDManaged() const
Return true if the file is hidden from the user point of view and is only managed by GDevelop.
Definition: SourceFile.h:65
gd::String GetFileName() const
Get the filename.
Definition: SourceFile.h:38
SourceFile * Clone() const
Return a pointer to a new SourceFile constructed from this one.
Definition: SourceFile.h:33
void SetFileName(gd::String filename_)
Change the filename.
Definition: SourceFile.h:43
void SetLanguage(gd::String lang)
Change the language of the source file.
Definition: SourceFile.h:70
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24
Definition: SourceFile.h:97