Fix INT_MAX definition on some newer systems.
[Tsunagari.git] / src / reader.h
blob3cb5a3d4d8fcb1144bcfa3e0956bee582c7e092b
1 /***************************************
2 ** Tsunagari Tile Engine **
3 ** reader.h **
4 ** Copyright 2011-2013 PariahSoft LLC **
5 ***************************************/
7 // **********
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // **********
27 #ifndef READER_H
28 #define READER_H
30 #include <string>
32 #include <libxml/parser.h>
34 #include "image.h"
35 #include "sound.h"
36 #include "tiledimage.h"
37 #include "xml.h"
39 namespace Gosu {
40 class Buffer;
41 class Sample;
42 class Song;
45 /**
46 * FIXME
47 * Provides data and resource extraction for a World.
48 * Each World comes bundled with associated data in the form of a Zip file.
49 * A Reader object knows how to navigate the data, extract individual
50 * requested files, and process the files into data structures. The final data
51 * structures are kept in memory for future requests.
53 class Reader
55 public:
56 static bool init(char* argv0);
57 static void deinit();
59 static bool prependPath(const std::string& path);
60 static bool appendPath(const std::string& path);
61 static bool rmPath(const std::string& path);
63 //! Returns true if the World contains a resource by that name.
64 static bool resourceExists(const std::string& name);
65 static bool directoryExists(const std::string& name);
66 static bool fileExists(const std::string& name);
68 static Gosu::Buffer* readBuffer(const std::string& name);
69 static std::string readString(const std::string& name);
71 //! Request an image from the World.
72 static ImageRef getImage(const std::string& name);
74 //! Request an image resource from the World and splits it into a
75 //! number of tiles that each have width and height w by h.
76 static TiledImageRef getTiledImage(const std::string& name,
77 int w, int h);
79 //! Request a sound object from the World. The sound will be
80 //! completely loaded into memory at once.
81 static SampleRef getSample(const std::string& name);
83 //! Request an XML document from the World.
84 static XMLRef getXMLDoc(const std::string& name,
85 const std::string& dtdPath);
87 //! Request a text file from the World.
88 static std::string getText(const std::string& name);
90 //! Expunge old resources cached in memory. Decisions on which are
91 //! removed and which are kept are based on the global Conf struct.
92 static void garbageCollect();
95 void exportReader();
97 #endif