-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGroundFunc.cpp
49 lines (40 loc) · 1.33 KB
/
GroundFunc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "Domain.h"
template <>
void GroundFunc<double>::PDDLPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) {
tabindent( s, indent );
s << "( = ";
TypeGround::PDDLPrint( s, 0, ts, d );
s << " " << ( int )value << " )";
}
template <>
void GroundFunc<int>::PDDLPrint( std::ostream & s, unsigned indent, const TokenStruct< std::string > & ts, Domain & d ) {
tabindent( s, indent );
s << "( = ";
TypeGround::PDDLPrint( s, 0, ts, d );
s << " " << d.types[((Function *)lifted)->returnType]->object( value ) << " )";
}
template <>
void GroundFunc<double>::parse( Filereader & f, TokenStruct< std::string > & ts, Domain & d ) {
TypeGround::parse( f, ts, d );
f.next();
std::string s = f.getToken();
std::istringstream i( s );
if ( !( i >> value ) ) f.tokenExit( s );
f.next();
f.assert( ")" );
}
template <>
void GroundFunc<int>::parse( Filereader & f, TokenStruct< std::string > & ts, Domain & d ) {
TypeGround::parse( f, ts, d );
f.next();
std::string s = f.getToken();
std::pair< bool, unsigned > p = d.types[((Function *)lifted)->returnType]->parseObject( s );
if ( p.first ) value = p.second;
else {
std::pair< bool, int > q = d.types[((Function *)lifted)->returnType]->parseConstant( s );
if ( q.first ) value = q.second;
else f.tokenExit( s );
}
f.next();
f.assert( ")" );
}