// // quickie - a small fast C++ Wiki Wiki // Copyright (C) 2005 Peter Miller // // 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, USA. // // MANIFEST: interface definition for cklinlen/check.cc // #ifndef CKLINLEN_CHECK_H #define CKLINLEN_CHECK_H #pragma interface "check" #include #include /** * The check class is used to represent the parse state when validating * a file. */ class check { public: /** * The destructor. */ virtual ~check(); /** * The constructor. */ check(const rcstring &filenmae); void run(); private: bool warning; int limit; int number_of_blank_lines; int number_of_errors; int line_number; bool dos_format; bool binary_format; FILE *fp; rcstring fn; bool isa_c_file; bool isa_cxx_file; bool isa_h_file; bool cxx_warning; bool unprintable_ok; /** * The run_state_machine function is used to track the C and C++ * comment state of the file. This allows us to generate warnings * about inappropriate comments. * * All C++ compilers accept C comments, and many C compilers accept C++ * comments (and a recent standard extention permits them). * However, file_check warns about cross-language comments. * * The rationale of this is that the comments give the human reader * an important clue as to which language they should expect to * be reading. While the semantic differences between C and C++ are * obviously different in many cases, in some cases they are merely * subltly different. Not all C code works identically in C++. * Consistent use of the approriate comment form gives the human reader * an obvious reminder. * * Exception: The Doxygen and DOC++ comment form is / * * blah * /, * and this is accepted in C++, mostly because Doxygen and DOC++ don't * treat runs of /// as a single block comment. Usually such comments * are isolated in the obviously different class declarations, so should * not be an issue. */ void run_state_machine(int); bool check_copyright(const rcstring &line); bool check_one_line(); enum state_t { state_normal, state_double_quote, state_double_quote_escape, state_single_quote, state_single_quote_escape, state_slash, state_cxx_comment, state_c_comment, state_c_comment_begin, state_c_comment_doxygen, state_c_comment_star }; state_t state; bool has_copyright; static rcstring user_name; static rcstring year; void check_c_comment(); /** * The default constructor. Do not use. */ check(); /** * The copy constructor. Do not use. */ check(const check &); /** * The assignment operator. Do not use. */ check &operator=(const check &); }; #endif // CKLINLEN_CHECK_H