TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
InfoFileParser.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012 Bruno Van de Velde (VDV_B@hotmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef _TGUI_INFO_FILE_PARSER_INCLUDED_
27 #define _TGUI_INFO_FILE_PARSER_INCLUDED_
28 
30 
31 namespace tgui
32 {
34  // Reads the info.txt files and finds the properties and their values in these files.
36  struct TGUI_API InfoFileParser : public sf::NonCopyable
37  {
39  // \brief Destructor. Closes the file if still open.
41  virtual ~InfoFileParser();
42 
43 
45  // Open a given file. If a file is already open then it will be closed first.
46  //
47  // return: true when the file was opened
48  // false when it couldn't be opened
50  virtual bool openFile(const std::string& filename);
51 
52 
54  // Reads the next line of the file, removes spaces and tabs, removes comments and then searches for an equal mark.
55  // The word before the equal mark is stored in property, everything after the equal mark is stored in Value.
56  // If the line is empty or if no equal mark was found the function will read the next line.
57  //
58  // return: true when a property was found
59  // false when the end of the file was reached
61  virtual bool readProperty(std::string& property, std::string& value);
62 
63 
65  // Close the file that was opened by the OpenFile function.
67  virtual void closeFile();
68 
69 
71  protected:
72 
73  std::ifstream m_File;
74  };
75 
77 
78 }
79 
81 
82 #endif //_TGUI_INFO_FILE_PARSER_INCLUDED_
83