| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2008 by Eran Ifrah |
| 5 |
// file name : cpp_scanner.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
#ifndef CODELITE_CPPSCANNER_H |
| 26 |
#define CODELITE_CPPSCANNER_H |
| 27 |
|
| 28 |
#include "FlexLexer.h" |
| 29 |
#include "smart_ptr.h" |
| 30 |
#include "codelite_exports.h" |
| 31 |
|
| 32 |
class WXDLLIMPEXP_CL CppScanner : public flex::yyFlexLexer |
| 33 |
{ |
| 34 |
public: |
| 35 |
CppScanner(); |
| 36 |
~CppScanner(void); |
| 37 |
|
| 38 |
/// Override the LexerInput function |
| 39 |
int LexerInput(char *buf, int max_size); |
| 40 |
void SetText(const char* data); |
| 41 |
void Reset(); |
| 42 |
|
| 43 |
|
| 44 |
/// Note about comment and line number: |
| 45 |
/// If the last text consumed is a comment, the line number |
| 46 |
/// returned is the line number of the last line of the comment |
| 47 |
/// incase the comment spans over number of lines |
| 48 |
/// (i.e. /* ... */ comment style) |
| 49 |
|
| 50 |
const int& LineNo() const { return yylineno; } |
| 51 |
inline void ClearComment() { m_comment = wxEmptyString; } |
| 52 |
inline const wxChar* GetComment() const { return m_comment.GetData(); } |
| 53 |
inline void KeepComment(const int& keep) { m_keepComments = keep; } |
| 54 |
inline void ReturnWhite(const int& rw) { m_returnWhite = rw; } |
| 55 |
void Restart(); |
| 56 |
|
| 57 |
private: |
| 58 |
char *m_data; |
| 59 |
char *m_pcurr; |
| 60 |
int m_total; |
| 61 |
int m_curr; |
| 62 |
}; |
| 63 |
|
| 64 |
typedef SmartPtr<CppScanner> CppScannerPtr; |
| 65 |
#endif // CODELITE_CPPSCANNER_H |