/*! \file pipacketextractor.h * \brief Packets extractor */ /* PIP - Platform Independent Primitives Packets extractor Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com 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 3 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, see . */ #ifndef CODE_H #define CODE_H #include "pifile.h" inline bool _isCChar(const PIChar & c) {return (c.isAlpha() || (c == '_'));} inline bool _isCChar(const PIString & c) {if (c.isEmpty()) return false; return _isCChar(c[0]);} class CodeParser { public: CodeParser(); bool parseFile(const PIString & file); private: void clear(); bool parseFileContent(PIString & fc); bool parseDirective(PIString d); enum Visibility {Global, Public, Protected, Private}; typedef PIPair Define; typedef PIPair Typedef; struct Macro { Macro(const PIString & n = PIString(), const PIString & v = PIString(), const PIStringList & a = PIStringList()) { name = n; value = v; args = a; } PIString expand(const PIStringList & arg_vals, bool * ok = 0) const; PIString name; PIString value; PIStringList args; }; struct Entity { Entity() { visibility = Global; size = 0; parent = 0; } PIString type; PIString name; PIString file; Visibility visibility; int size; Entity * parent; PIVector children; }; PIVector defines; PIVector macros; PIVector typedefs; PIVector entities; PIVector tree; }; #endif // PIPACKETEXTRACTOR_H