#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
Go to the source code of this file.
◆ get_lines()
vector<string> get_lines |
( |
vector< string > & |
input, |
|
|
int & |
linenum, |
|
|
string |
terminator |
|
) |
| |
Definition at line 66 of file gen_manual.cpp.
71 while ((
size_t)linenum <
input.size()) {
74 if (terminator.empty() &&
line.empty()) { linenum--;
break; }
76 size_t const epos =
line.find(terminator);
77 if (!terminator.empty() && epos!=string::npos) {
const lzma_allocator const uint8_t size_t uint8_t * out
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)
References input(), setup::line, and out.
Referenced by main().
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 106 of file gen_manual.cpp.
108 int linenum, chapter = 1;
109 vector<string>
input,
lines, comments, chapters;
117 cout <<
"usage: " <<
argv[0] <<
" [lz4_version] [input_file] [output_html]" << endl;
124 if (!istream.is_open()) {
125 cout <<
"Error opening file " <<
argv[2] << endl;
130 if (!ostream.is_open()) {
131 cout <<
"Error opening file " <<
argv[3] << endl;
135 while (getline(istream,
line)) {
139 for (linenum=0; (
size_t)linenum <
input.size(); linenum++) {
143 if (
line.substr(0,7) ==
"typedef" &&
line.find(
"{")!=string::npos) {
146 for (l=0; l<
lines.size(); l++) {
149 sout <<
"</b></pre><BR>" << endl;
154 if ((
line.find(
"/**<")!=string::npos ||
line.find(
"/*!<")!=string::npos)
155 &&
line.find(
"*/")!=string::npos) {
158 sout <<
"</b></pre><BR>" << endl;
162 spos =
line.find(
"/**=");
163 if (spos==string::npos) {
164 spos =
line.find(
"/*!");
165 if (spos==string::npos)
166 spos =
line.find(
"/**");
167 if (spos==string::npos)
168 spos =
line.find(
"/*-");
169 if (spos==string::npos)
170 spos =
line.find(
"/*=");
171 if (spos==string::npos)
173 exclam =
line[spos+2];
178 if (!comments.empty()) comments[0] =
line.substr(spos+3);
179 if (!comments.empty())
180 comments[comments.size()-1] = comments[comments.size()-1].substr(0, comments[comments.size()-1].find(
"*/"));
181 for (l=0; l<comments.size(); l++) {
182 if (comments[l].
compare(0, 2,
" *") == 0)
183 comments[l] = comments[l].substr(2);
184 else if (comments[l].
compare(0, 3,
" *") == 0)
185 comments[l] = comments[l].substr(3);
186 trim(comments[l],
"*-=");
188 while (!comments.empty() && comments[comments.size()-1].empty()) comments.pop_back();
189 while (!comments.empty() && comments[0].empty()) comments.erase(comments.begin());
193 if (!comments.empty()) comments.erase(comments.begin());
198 for (l=0; l<
lines.size(); l++) {
202 for (l=0; l<comments.size(); l++) {
205 sout <<
"</p></pre><BR>" << endl << endl;
206 }
else if (exclam ==
'=') {
207 trim(comments[0],
" ");
208 sout <<
"<h3>" << comments[0] <<
"</h3><pre>";
209 for (l=1; l<comments.size(); l++) {
212 sout <<
"</pre><b><pre>";
214 for (l=0; l<
lines.size(); l++) {
217 sout <<
"</pre></b><BR>" << endl;
219 if (comments.empty())
continue;
221 trim(comments[0],
" ");
222 sout <<
"<a name=\"Chapter" << chapter <<
"\"></a><h2>" << comments[0] <<
"</h2><pre>";
223 chapters.push_back(comments[0]);
226 for (l=1; l<comments.size(); l++) {
229 if (comments.size() > 1)
230 sout <<
"<BR></pre>" << endl << endl;
232 sout <<
"</pre>" << endl << endl;
236 ostream <<
"<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n<title>" <<
version <<
"</title>\n</head>\n<body>" << endl;
237 ostream <<
"<h1>" <<
version <<
"</h1>\n";
239 ostream <<
"<hr>\n<a name=\"Contents\"></a><h2>Contents</h2>\n<ol>\n";
240 for (
size_t i=0;
i<chapters.size();
i++)
241 ostream <<
"<li><a href=\"#Chapter" <<
i+1 <<
"\">" << chapters[
i].c_str() <<
"</a></li>\n";
242 ostream <<
"</ol>\n<hr>\n";
244 ostream << sout.str();
245 ostream <<
"</html>" << endl <<
"</body>" << endl;
static RzBinSourceLineInfo * lines(RzBinFile *bf)
const lzma_allocator const uint8_t * in
vector< string > get_lines(vector< string > &input, int &linenum, string terminator)
void print_line(stringstream &sout, string line)
void trim(string &s, string characters)
static int compare(const char *s1, const char *s2, int l1, int l2)
static static fork const void static count static fd const char const char static newpath char char argv
References argv, compare(), get_lines(), i, in, input(), setup::line, lines(), out, print_line(), trim(), and version.
◆ print_line()
void print_line |
( |
stringstream & |
sout, |
|
|
string |
line |
|
) |
| |
Definition at line 89 of file gen_manual.cpp.
93 if (
line.substr(0,11) ==
"LZ4LIB_API ")
line =
line.substr(11);
94 if (
line.substr(0,12) ==
"LZ4FLIB_API ")
line =
line.substr(12);
95 spos =
line.find(
"/*");
96 epos =
line.find(
"*/");
97 if (spos!=string::npos && epos!=string::npos) {
98 sout <<
line.substr(0, spos);
99 sout <<
"</b>" <<
line.substr(spos) <<
"<b>" <<
'\n';
101 sout <<
line <<
'\n';
References setup::line.
Referenced by main().
◆ trim()
void trim |
( |
string & |
s, |
|
|
string |
characters |
|
) |
| |
◆ trim_comments()
void trim_comments |
( |
string & |
s | ) |
|
Definition at line 55 of file gen_manual.cpp.
61 s =
s.substr(spos+3, epos-(spos+3));
References s.