Dynalib Utils
File.h
Go to the documentation of this file.
1 #ifndef KAML_FILE_H
2 #define KAML_FILE_H
3 
4 #include <cstdio>
5 #include "../String.h"
6 #include "../DynaList.h"
7 #include "../IntWrapper.h"
8 #include "../Graph/Node.h"
9 
10 using namespace Graph;
11 
12 namespace KAML {
13 
14  class File : public IHashable<File>, public ICopyable<File> {
15  FILE* _file = nullptr;
16  Node* _rootNode = nullptr;
17  const String* _fileName = nullptr;
18 
19  void _init(const String& fileName);
20 
21  public:
22  File();
23  explicit File(const String& fileName);
24  virtual ~File();
25  File(const File& other);
26  File* copy() override;
27 
28  static bool exists(const String& fileName);
29  static bool canAccess(const String& fileName);
30 
31  bool isOpen();
32  bool open(const String& fileName, const char* mode);
33  const String* getFileName() const;
34  size_t read(String& buf);
35  void close();
36  bool save();
37  bool saveAs(const String& fileName);
38 
39  // void setRootNode(Node* rootNode);
40  Node& getRootNode();
41  Node& getDoc(int index = 0);
42 
43  int hashCode() const override;
44  bool operator== (const File &other) const override;
45  };
46 
47 }
48 
49 #endif
CONSTCD11 bool operator==(const day &x, const day &y) NOEXCEPT
Definition: date.h:1274
Definition: IHashable.h:10
void read(std::basic_istream< CharT, Traits > &)
Definition: date.h:5845
Definition: String.h:60
Definition: Node.h:47
Definition: File.cpp:10
Definition: Node.cpp:13
Definition: File.h:14
int hashCode(bool key)
Definition: HashCoder.cpp:27
Definition: ICopyable.h:8