-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cpp
50 lines (39 loc) · 954 Bytes
/
main.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
50
/*
* main.cpp
*
* Created on: 2014.
* Author: jc
*/
#include <Context/Context.h>
#include <Exception/Exception.h>
#include <Template/FileTemplate.h>
#include <fstream>
#include <iostream>
#include <string>
using namespace json11;
int main( int argc, char ** argv )
{
RedZone::FileTemplate tpl( "test.tpl" );
std::ifstream jsonIn( "test.json" );
if( !jsonIn.good() ) {
return 1;
}
std::string err;
Json json( Json::parse(
std::string(
std::istreambuf_iterator< char >( jsonIn ),
std::istreambuf_iterator< char >() ),
err ) );
if( err.length() ) {
std::cerr << err << std::endl;
return 1;
}
RedZone::Context * cont( new RedZone::Context( json ) );
try {
std::cout << tpl.render( cont ) << std::endl;
}
catch( RedZone::Exception const & exception ) {
std::cerr << exception.what() << std::endl;
}
return 0;
}