]> git.tdb.fi Git - libs/datafile.git/blob - source/statement.h
Add an easier way to construct statements for writing
[libs/datafile.git] / source / statement.h
1 /* $Id$
2
3 This file is part of libmspdatafile
4 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7 #ifndef MSP_DATAFILE_STATEMENT_H_
8 #define MSP_DATAFILE_STATEMENT_H_
9
10 #include <list>
11 #include "value.h"
12
13 namespace Msp {
14 namespace DataFile {
15
16 class Statement
17 {
18 public:
19         std::string keyword;
20         ValueArray  args;
21         bool        valid;
22         std::string source;
23         unsigned    line;
24         std::list<Statement> sub;
25
26         Statement(): valid(false), line(0) { }
27         Statement(const std::string &kw): keyword(kw), valid(true), line(0) { }
28         std::string get_location() const;
29         
30         template<typename T>
31         Statement &append(const T &v)
32         {
33                 args.push_back(Value(v));
34                 return *this;
35         }
36
37         template<typename T>
38         Statement &operator,(const T &v)
39         { return append(v); }
40 };
41
42 } // namespace DataFile
43 } // namespace Msp
44
45 #endif