Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules / test / include / dpl / test / value_separated_reader.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @file        value_separated_reader.h
18  * @author      Tomasz Iwanek (t.iwanek@samsung.com)
19  * @brief       Reader for some value seperated files/data
20  *
21  * This is parser for files containing lines with values seperated with custom charaters.
22  * Purpose of this is to parse output similar to csv and hide (no need for rewriting)
23  * buffers, reads, code errors. Result is two dimensional array.
24  *
25  * Reader is designed as class configured with policies classes:
26  *  http://en.wikipedia.org/wiki/Policy-based_design
27  */
28
29 #ifndef VALUE_SEPARATED_READER_H
30 #define VALUE_SEPARATED_READER_H
31
32 #include<dpl/test/abstract_input_reader.h>
33 #include<dpl/test/value_separated_tokenizer.h>
34 #include<dpl/test/value_separated_parser.h>
35 #include<dpl/test/value_separated_tokens.h>
36 #include<dpl/test/value_separated_policies.h>
37
38 namespace DPL {
39
40 /**
41  * Reader for input with values separated with defined characters
42  *
43  * Usage:
44  * - define both policies classes for defining and customize exact behaviour of reader
45  * - make typedef for VSReader template instance with your policies
46  *
47  */
48 template<class ParserPolicy, class TokenizerPolicy>
49 class VSReader : public AbstractInputReader<VSResultPtr, VSToken>
50 {
51 public:
52     VSReader(std::shared_ptr<AbstractInput> wia)
53         : AbstractInputReader<VSResultPtr, VSToken>(wia,
54                 std::unique_ptr<ParserBase>(new VSParser<ParserPolicy>()),
55                 std::unique_ptr<TokenizerBase>(new VSTokenizer<TokenizerPolicy>()))
56     {}
57 };
58
59 typedef VSReader<CSVParserPolicy, CSVTokenizerPolicy> CSVReader;
60
61 }
62
63 #endif