OMNeT++ NEDXML  6.0.3
sourcedocument.h
Go to the documentation of this file.
1 //==========================================================================
2 // SOURCEDOCUMENT.H - part of
3 //
4 // OMNeT++/OMNEST
5 // Discrete System Simulation in C++
6 //
7 //==========================================================================
8 
9 /*--------------------------------------------------------------*
10  Copyright (C) 2002-2017 Andras Varga
11  Copyright (C) 2006-2017 OpenSim Ltd.
12 
13  This file is distributed WITHOUT ANY WARRANTY. See the file
14  `license' for details on this and other legal matters.
15 *--------------------------------------------------------------*/
16 
17 #ifndef __OMNETPP_NEDXML_SOURCEDOCUMENT_H
18 #define __OMNETPP_NEDXML_SOURCEDOCUMENT_H
19 
20 #include "nedxmldefs.h"
21 
22 namespace omnetpp {
23 namespace nedxml {
24 
25 struct YYLoc;
26 
38 {
39  private:
40  enum {COMMENT_LINE, BLANK_LINE, CODE_LINE};
41 
42  char *wholeFile = nullptr;
43 
44  int numLines = 0;
45  char **lineBeg = nullptr;
46 
47  char *end = nullptr;
48  char savedChar = 0;
49 
50  int commentBufLen = 1024; // has to be before commentBuf to get initialized before it
51  char *commentBuf;
52 
53  private:
54  int getLineType(int lineNumber);
55  int getLineType(const char *s);
56  bool lineContainsCode(const char *s);
57  int getLineIndent(int lineNumber);
58  int getLineIndent(const char *s);
59  char *getPosition(int line, int column);
60 
61  bool indexLines();
62  int topLineOfBannerComment(int li);
63  char *stripComment(const char *s);
64 
65  YYLoc getFileCommentPos();
66  YYLoc getBannerCommentPos(YYLoc pos);
67  YYLoc getTrailingCommentPos(YYLoc pos);
68 
69  public:
74 
78  ~SourceDocument();
79 
85  bool readFile(const char *filename);
86 
92  bool setData(const char *data);
93 
101  const char *get(YYLoc pos);
102 
106  const char *getFileComment();
107 
111  const char *getBannerComment(YYLoc pos);
112 
116  const char *getTrailingComment(YYLoc pos);
117 
122  const char *getNextInnerComment(YYLoc& pos);
123 
127  YYLoc getFullTextPos();
128 
132  const char *getFullText();
133 
138  void trimSpaceAndComments(YYLoc& pos);
139 };
140 
141 } // namespace nedxml
142 } // namespace omnetpp
143 
144 
145 #endif
146 
omnetpp::nedxml::SourceDocument
Stores the full text of a NED/MSG file.
Definition: sourcedocument.h:37
omnetpp::nedxml::YYLoc
Definition: yydefs.h:37
omnetpp::nedxml::pos
LineColumn pos
NEDXML_API
#define NEDXML_API
Definition: nedxmldefs.h:31
omnetpp
Definition: astbuilder.h:25
nedxmldefs.h