2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file value_separated_reader.h
18 * @author Tomasz Iwanek (t.iwanek@samsung.com)
19 * @brief Reader for some value seperated files/data
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.
25 * Reader is designed as class configured with policies classes:
26 * http://en.wikipedia.org/wiki/Policy-based_design
29 #ifndef VALUE_SEPARATED_READER_H
30 #define VALUE_SEPARATED_READER_H
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>
41 * Reader for input with values separated with defined characters
44 * - define both policies classes for defining and customize exact behaviour of reader
45 * - make typedef for VSReader template instance with your policies
48 template<class ParserPolicy, class TokenizerPolicy>
49 class VSReader : public AbstractInputReader<VSResultPtr, VSToken>
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>()))
59 typedef VSReader<CSVParserPolicy, CSVTokenizerPolicy> CSVReader;