Colobot
parser.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
30 
31 #include <string>
32 #include <vector>
33 
35 {
36 public:
38  CLevelParser();
40  CLevelParser(std::string filename);
42  CLevelParser(std::string category, int chapter, int rank);
43 
44  ~CLevelParser();
45 
47  static std::string BuildCategoryPath(std::string category);
49  static std::string BuildScenePath(std::string category, int chapter, int rank, bool sceneFile = true);
50 
52  bool Exists();
54  void Load();
56  void Save();
57 
59  const std::string& GetFilename();
60 
62  std::vector<CLevelParserLine*> GetLines();
64  void AddLine(CLevelParserLine* line);
65 
67  CLevelParserLine* Get(std::string command);
68 
69 private:
70  std::string m_filename;
71  std::vector<CLevelParserLine*> m_lines;
72 };
Value of command argument in level file.
static std::string BuildCategoryPath(std::string category)
Build category path.
Definition: parser.cpp:65
Exceptions that could be thrown in level parser.
CLevelParser()
Create an empty level file.
Definition: parser.cpp:42
const std::string & GetFilename()
Get filename.
Definition: parser.cpp:254
void AddLine(CLevelParserLine *line)
Insert new line to file.
Definition: parser.cpp:264
Definition: parserline.h:33
void Save()
Save file.
Definition: parser.cpp:236
static std::string BuildScenePath(std::string category, int chapter, int rank, bool sceneFile=true)
Build level filename.
Definition: parser.cpp:80
bool Exists()
Check if level file exists.
Definition: parser.cpp:133
void Load()
Load file.
Definition: parser.cpp:138
Definition: parser.h:34
CLevelParserLine * Get(std::string command)
Find first line with given command.
Definition: parser.cpp:270
Class for one line from level file.
std::vector< CLevelParserLine * > GetLines()
Get all lines from file.
Definition: parser.cpp:259