17 #include "gxsys/RegularExpression.hxx"
18 #include "gxsys/ios/fstream"
19 #include "gxsys/ios/sstream"
107 gxsys_ios::ifstream file(this->
GetFileName().c_str());
118 bool isLineComment =
false;
120 gxsys::RegularExpression reLineComment;
121 reLineComment.compile(
"^[\\t ]*//");
123 gxsys::RegularExpression reBTX;
124 gxsys::RegularExpression reETX;
125 if (trackBtxEtxLevel)
140 file.getline(line, 4099);
142 isLineComment = reLineComment.find(line);
144 if (trackBtxEtxLevel && reBTX.find(line))
149 this->
Lines.push_back(
LineData(line, isLineComment, btxEtxLevel));
151 if (trackBtxEtxLevel && reETX.find(line))
163 gxsys_stl::ostringstream oss;
165 oss <<
"FileName: " << this->
FileName << gxsys_stl::endl;
168 oss <<
"EndExcludeRegex: " << this->
EndExcludeRegex << gxsys_stl::endl;
170 oss <<
"Lines:" << gxsys_stl::endl;
173 gxsys_stl::vector<LineData>::iterator itLines;
175 for (itLines = this->
Lines.begin(); itLines != this->
Lines.end();
209 gxsys_stl::streamsize w = oss.width();
218 oss <<
": " << line.
Line << gxsys_stl::endl;
223 Trace(oss.str().c_str());
231 return static_cast<unsigned int>(this->
Lines.size());
244 return this->
Lines.at(lineNumber-1).Line;
257 return this->
Lines.at(lineNumber-1).IsLineComment;
270 return this->
Lines.at(lineNumber-1).BtxEtxLevel;
305 unsigned int begin = 0;
306 unsigned int end = 0;
307 unsigned int i = lineNumber;
312 while (0 == end && i>1)
326 while (0 == begin && i>1)
349 "No comment lines prior to line " << lineNumber <<
". Undocumented class or method?");
351 else if (smallestAcceptableLineNumber > begin)
353 block.push_back(std::string(
"//Undocumented Block"));
359 gxsys::RegularExpression reBeginsWithWhiteSpace;
360 reBeginsWithWhiteSpace.compile(
"^([\\t ]*)[^\\t ].*");
364 for (i= begin; i<=end; ++i)
368 if (reBeginsWithWhiteSpace.find(s))
370 from = reBeginsWithWhiteSpace.match(1).size();
371 to = s.size() - from;
372 s = s.substr(from, to);
389 bool foundFirstComment =
false;
391 for (i= 1; i<=n; ++i)
395 foundFirstComment =
true;
397 else if (foundFirstComment)
virtual void GetFirstCommentBlock(gxsys_stl::vector< gxsys_stl::string > &block)
Retrieve the first block of comment lines, if any, in the file.
MummyLineOrientedTextFileReader()
virtual void SetFileName(const char *filename)
Set the filename.
virtual int GetBtxEtxLevel(unsigned int lineNumber)
Get the current nesting level at line number 'lineNumber' of "//BTX - //ETX" style wrapper exclusion ...
virtual ~MummyLineOrientedTextFileReader()
virtual bool GetIsLineComment(unsigned int lineNumber)
Query if line number 'lineNumber' is a "line comment." Valid 'lineNumber' values are 1 through GetNum...
virtual void SetEndExcludeRegex(const gxsys_stl::string &endExcludeRegex)
Set the regular expression that delineates a line as the end of a "marked as excluded" block...
virtual gxsys_stl::string GetFileName()
Get the filename.
virtual gxsys_stl::string GetEndExcludeRegex()
Get the regular expression that delineates a line as the end of a "marked as excluded" block...
Internal, implementation detail class that caches information associated with a line in a line orient...
virtual unsigned int GetNumberOfLines()
Retrieve the total number of lines currently cached.
gxsys_stl::string BeginExcludeRegex
virtual void SetExcludeMarkedLines(bool excludeMarkedLines)
Set whether to exclude lines between beginExcludeRegex and endExcludeRegex matching lines when consid...
virtual gxsys_stl::string GetBeginExcludeRegex()
Get the regular expression that delineates a line as the beginning of a "marked as excluded" block...
virtual void SetBeginExcludeRegex(const gxsys_stl::string &beginExcludeRegex)
Set the regular expression that delineates a line as the beginning of a "marked as excluded" block...
virtual bool IsLineExcluded(unsigned int lineNumber)
Query whether the given line number should be excluded based on the exclude flag and the line number'...
gxsys_stl::vector< LineData > Lines
gxsys_stl::string FileName
virtual void Update()
Read the current text file and cache its lines for subsequent quick lookup by line number...
virtual void GetCommentBlockBefore(unsigned int lineNumber, gxsys_stl::vector< gxsys_stl::string > &block, unsigned int smallestAcceptableLineNumber)
Retrieve the nearest preceding block of comment lines relative to line number 'lineNumber'. Valid 'lineNumber' values are 2 through GetNumberOfLines inclusive.
gxsys_stl::string EndExcludeRegex
virtual bool GetExcludeMarkedLines()
Get whether to exclude lines between beginExcludeRegex and endExcludeRegex matching lines when consid...
void Trace(const char *s)
virtual gxsys_stl::string GetLine(unsigned int lineNumber)
Retrieve line number 'lineNumber' as a string from the currently cached text file. Valid 'lineNumber' values are 1 through GetNumberOfLines inclusive.
#define LogFileLineWarningMsg(file, line, n, m)