A simple widget to visualise a set of example source files.
More...
#include <ExampleSourceViewer.h>
|
| ExampleSourceViewer (const std::string &deployPath, const std::string &examplesRoot, const std::string &examplesType) |
| Constructor. More...
|
|
A simple widget to visualise a set of example source files.
Definition at line 21 of file ExampleSourceViewer.h.
ExampleSourceViewer::ExampleSourceViewer |
( |
const std::string & |
deployPath, |
|
|
const std::string & |
examplesRoot, |
|
|
const std::string & |
examplesType |
|
) |
| |
void ExampleSourceViewer::cppTraverseDir |
( |
Wt::WStandardItem * |
parent, |
|
|
const boost::filesystem::path & |
path |
|
) |
| |
|
private |
Definition at line 194 of file ExampleSourceViewer.C.
197 static const char *supportedFiles[] = {
198 ".C",
".cpp",
".h",
".css",
".xml",
".png",
".gif",
".csv",
".ico", 0
206 std::set<fs::path> paths;
208 fs::directory_iterator end_itr;
209 for (fs::directory_iterator i(path); i != end_itr; ++i)
212 std::vector<FileItem*> classes, files;
213 std::vector<fs::path> dirs;
215 while (!paths.empty()) {
216 fs::path p = *paths.begin();
220 if (fs::is_symlink(p))
224 if (fs::is_regular(p)) {
225 std::string ext = fs::extension(p);
226 bool supported =
false;
227 for (
const char **s = supportedFiles; *s != 0; ++s)
239 if (!companion.empty()) {
240 std::set<fs::path>::iterator it_companion = paths.find(companion);
242 if (it_companion != paths.end()) {
243 std::string className =
stem(p);
244 escapeText(className);
245 std::string label =
"<i>class</i> " + className;
248 new FileItem(
"/icons/cppclass.png", label, std::string());
255 (*it_companion).string());
259 classes.push_back(classItem);
260 paths.erase(it_companion);
264 files.push_back(file);
266 }
else if (fs::is_directory(p)) {
271 files.push_back(file);
277 for (
unsigned int i = 0; i < classes.size(); i++)
280 for (
unsigned int i = 0; i < files.size(); i++)
283 for (
unsigned int i = 0; i < dirs.size(); i++)
285 }
catch (fs::filesystem_error& e) {
286 std::cerr << e.what() << std::endl;
void ExampleSourceViewer::handlePathChange |
( |
| ) |
|
|
private |
Definition at line 84 of file ExampleSourceViewer.C.
91 if (example.find(
"..") != std::string::npos
92 || example.find(
'/') != std::string::npos
93 || example.find(
'\\') != std::string::npos) {
void ExampleSourceViewer::javaTraverseDir |
( |
Wt::WStandardItem * |
parent, |
|
|
const boost::filesystem::path & |
path |
|
) |
| |
|
private |
Definition at line 324 of file ExampleSourceViewer.C.
332 std::vector<fs::path> files, dirs;
334 fs::directory_iterator end_itr;
335 for (fs::directory_iterator i(path); i != end_itr; ++i) {
337 if (fs::is_directory(p)) {
353 for (
unsigned int i = 0; i < dirs.size(); i++)
356 for (
unsigned int i = 0; i < files.size(); i++) {
void ExampleSourceViewer::javaTraversePackages |
( |
Wt::WStandardItem * |
parent, |
|
|
const boost::filesystem::path & |
srcPath, |
|
|
const std::string |
packageName |
|
) |
| |
|
private |
Definition at line 290 of file ExampleSourceViewer.C.
294 fs::directory_iterator end_itr;
297 for (fs::directory_iterator i(srcPath); i != end_itr; ++i) {
299 if (fs::is_regular(p)) {
301 packageItem =
new FileItem(
"/icons/package.png", packageName,
"");
311 for (fs::directory_iterator i(srcPath); i != end_itr; ++i) {
313 if (fs::is_directory(p)) {
314 std::string pn = packageName;
void ExampleSourceViewer::setExample |
( |
const std::string & |
exampleDir, |
|
|
const std::string & |
example |
|
) |
| |
|
private |
Definition at line 101 of file ExampleSourceViewer.C.
108 exists = fs::exists(exampleDir);
109 }
catch (std::exception&) {
113 WApplication::instance()->setInternalPathValid(
false);
114 addWidget(
new WText(
"No such example: " + exampleDir));
125 WApplication::instance()->setTitle(tr(
"srcview.title." + example));
128 title->setInternalPathEncoding(
true);
175 setLayout(topLayout);
void ExampleSourceViewer::showFile |
( |
| ) |
|
|
private |
std::string ExampleSourceViewer::deployPath_ |
|
private |
std::string ExampleSourceViewer::examplesRoot_ |
|
private |
std::string ExampleSourceViewer::examplesType_ |
|
private |
The documentation for this class was generated from the following files: