Overpass API regression suite coverage (Nova Scotia) / expat/map_ql_input.cc
expat/map_ql_input.cc
349 of 418 instrumented lines run by the suite (83.5%) at 8edf11b0419c (this file on GitHub).
runnever runcolumns: line, executions, queries (click for the queries that run the line)
1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.2 *3 * This file is part of Overpass_API.4 *5 * Overpass_API is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as7 * published by the Free Software Foundation, either version 3 of the8 * License, or (at your option) any later version.9 *10 * Overpass_API is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.17 */19#include "map_ql_input.h"21#include <cctype>22#include <fstream>23#include <iostream>24#include <queue>25#include <set>26#include <vector>29//-----------------------------------------------------------------------------31template< class In >32class Comment_Replacer33{34 Comment_Replacer(const Comment_Replacer&);35 Comment_Replacer& operator=(const Comment_Replacer&);37 public:41 void get(char& c);43 // The line and the column of the next character to read.46 private:47 In& in;48 char buffer;49 enum { invalid, read, written, escaped } buffer_state;50 enum { plainfile, single_quot, double_quot } state;51 uint line;52 uint col;53};55template< class In >56inline void Comment_Replacer< In >::get(char& c)58 // If a buffer exists, it must be cleared first.78 // Adjust line and column counter87 // We've got a valid character. Process it with regard to the state.117 // state == plainfile173//-----------------------------------------------------------------------------175template< class In >176class Whitespace_Compressor177{178 // Don't copy or assign.179 Whitespace_Compressor(const Whitespace_Compressor&);180 Whitespace_Compressor& operator=(const Whitespace_Compressor&);182 public:186 void get(char& c);188 // The line and the column of the next character to read.189 std::pair< uint, uint > line_col();191 private:192 In& in;193 char buffer;194 std::pair< uint, uint > buffer_line_col;195 enum { invalid, read, written, escaped } buffer_state;196 enum { plainfile, single_quot, double_quot } state;197};199template< class In >200inline void Whitespace_Compressor< In >::get(char& c)202 // If a buffer exists, it must be cleared first.222 // We've got a valid character. Process it with regard to the state.254 // state == plainfile275template< class In >276inline std::pair< uint, uint > Whitespace_Compressor< In >::line_col()284//-----------------------------------------------------------------------------286template< class In >287class Tokenizer288{289 Tokenizer(const Tokenizer&);290 Tokenizer& operator=(const Tokenizer&);292 public:293 Tokenizer(In& in_);295 void get(std::string& s);297 // The line and the column of the next token to read.298 std::pair< uint, uint > line_col();300 private:301 In& in;302 std::string buffer;303 std::queue< std::pair< uint, uint > > line_cols;304 void grow_buffer(unsigned int size);305 void probe(std::string& s, const std::string& probe1, const std::string& probe2 = "");306 void clear_space();307};309template< class In >315template< class In >316inline void Tokenizer< In >::grow_buffer(unsigned int size)334template< class In >335inline void Tokenizer< In >::probe336 (std::string& s, const std::string& probe1, const std::string& probe2)365template< class In >366inline void Tokenizer< In >::clear_space()378void pop_front(std::string& s, std::string& buffer, unsigned int num_bytes)385template< class In >386inline void Tokenizer< In >::get(std::string& s)544template< class In >545inline std::pair< uint, uint > Tokenizer< In >::line_col()553//-----------------------------------------------------------------------------555Tokenizer_Wrapper::Tokenizer_Wrapper(std::istream& in_)5592416604 q in = new Tokenizer< Whitespace_Compressor< Comment_Replacer< std::istream > > >(*inwsc);565void Tokenizer_Wrapper::operator++()572Tokenizer_Wrapper::~Tokenizer_Wrapper()