GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/FileParser/TESTS/TEST_MULTI_FILE_PARSER/ConfigParser.cpp Lines: 29 29 100.0 %
Date: 2023-10-11 10:52:07 Branches: 22 23 95.7 %

Line Branch Exec Source
1
/***************************************
2
	Auteur : Pierre Aubert
3
	Mail : pierre.aubert@lapp.in2p3.fr
4
	Licence : CeCILL-C
5
****************************************/
6
7
#include "string_utils.h"
8
#include "ConfigParser.h"
9
10
///Default constructor of ConfigParser
11
2
ConfigParser::ConfigParser(){
12
2
	initialisationConfigParser();
13
2
}
14
15
///Destructor of ConfigParser
16
4
ConfigParser::~ConfigParser(){
17
18
}
19
20
///Get the last doc string
21
/**	@return last doc string
22
*/
23
2
const std::string & ConfigParser::getDocString() const{
24
2
	return p_lastDocString;
25
}
26
27
///Parse the input file
28
/**	@return true on success, false otherwise
29
*/
30
5
bool ConfigParser::parseFile(){
31
5
	if(!p_run) return false;
32
33
5
	p_parser->skipWhiteSpace();
34
	//To parse the file we need to read char by char until we get something we know
35
5
	if(parseDocString()){}
36

3
	else if(isMatch("//")){p_parser->getUntilKeyWithoutPatern("\n");}	//Skip comment
37
	else{
38
1
		unexpectedToken();
39
1
		pointAtRow();
40
1
		return false;
41
	}
42
4
	p_parser->skipWhiteSpace();
43
4
	return true;
44
}
45
46
///Initialisation to be done just before loading a file
47
3
void ConfigParser::preLoadFile(){
48
	//Save the current source
49
3
	getCurrentParser()->setWhiteSpace(" \t\n");
50
3
	getCurrentParser()->setSeparator(",;{}[]()");
51
3
	p_lastDocString = "";
52
3
}
53
54
///Initialisation to be done just after loading a file
55
2
void ConfigParser::postLoadFile(){
56
57
2
}
58
59
///Initialisation function of the class ConfigParser
60
2
void ConfigParser::initialisationConfigParser(){
61
62
2
}
63
64
///Parse a doc string
65
/**	@return true on success, false otherwise
66
*/
67
5
bool ConfigParser::parseDocString(){
68

5
	if(!isMatch("///")){return false;}
69
2
	p_lastDocString = p_parser->getUntilKeyWithoutPatern("\n");
70
71
2
	return true;
72
}
73
74
75
76