// Clint - Source code checker for C++
// Copyright (C) 2001 David Pashley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef __INPUT_H__
#define __INPUT_H__
#include <iostream>
#include <fstream>
#include <string>
#include <stack>
#include <map>
#include <vector>
namespace clint {
struct Pair {
std::string first;
std::string second;
};
// Input is a singleton.
// Get access to it through Input::instance()
class Input {
private:
struct File_Status {
std::istream * input;
std::string file;
int line;
};
std::stack<File_Status> m_file_status;
File_Status m_cur_file;
static Input * m_instance;
bool m_input_set;
std::vector<std::string> m_includes; // directories of system headers
std::map<std::string, std::string> m_defines;
std::string parse_cpp(std::string line);
Input();
public:
static Input * instance();
void set_input(std::string filename);
const Pair getline();
bool eof() const;
const int line() const;
const std::string file() const;
void add_include(std::string include);
void add_define(std::string define, std::string value);
bool is_system_header() const;
bool is_header() const;
};
}
#endif // __INPUT_H__
syntax highlighted by Code2HTML, v. 0.9.1