Wt examples  4.10.4
Functions
ExampleSourceViewer.C File Reference
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <Wt/WApplication.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WEnvironment.h>
#include <Wt/WLineEdit.h>
#include <Wt/WGridLayout.h>
#include <Wt/WHBoxLayout.h>
#include <Wt/WPushButton.h>
#include <Wt/WTable.h>
#include <Wt/WText.h>
#include <Wt/WTreeView.h>
#include <Wt/WVBoxLayout.h>
#include <Wt/WViewWidget.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/algorithm/string.hpp>
#include "ExampleSourceViewer.h"
#include "FileItem.h"

Go to the source code of this file.

Functions

static std::string filename (const fs::path &p)
 
static std::string stem (const fs::path &p)
 
fs::path parent_path (const fs::path &p)
 
static bool comparePaths (const fs::path &p1, const fs::path &p2)
 
static fs::path getCompanion (const fs::path &path)
 

Function Documentation

◆ comparePaths()

static bool comparePaths ( const fs::path &  p1,
const fs::path &  p2 
)
static

Definition at line 65 of file ExampleSourceViewer.C.

66 {
67  return filename(p1) > filename(p2);
68 }
static std::string filename(const fs::path &p)

◆ filename()

static std::string filename ( const fs::path &  p)
static

Definition at line 35 of file ExampleSourceViewer.C.

36 {
37 #if BOOST_FILESYSTEM_VERSION < 3
38  return p.empty() ? std::string() : *--p.end();
39 #else
40  return p.empty() ? std::string() : (*--p.end()).string();
41 #endif
42 }

◆ getCompanion()

static fs::path getCompanion ( const fs::path &  path)
static

Definition at line 185 of file ExampleSourceViewer.C.

186 {
187  std::string ext = fs::extension(path);
188 
189  if (ext == ".h")
190  return parent_path(path) / (stem(path) + ".C");
191  else if (ext == ".C" || ext == ".cpp")
192  return parent_path(path) / (stem(path) + ".h");
193  else
194  return fs::path();
195 }
static std::string stem(const fs::path &p)
fs::path parent_path(const fs::path &p)

◆ parent_path()

fs::path parent_path ( const fs::path &  p)

Definition at line 57 of file ExampleSourceViewer.C.

58 {
59  std::string fn = filename(p);
60  std::string path = p.string();
61 
62  return path.substr(0, path.length() - fn.length() - 1);
63 }

◆ stem()

static std::string stem ( const fs::path &  p)
static

Definition at line 45 of file ExampleSourceViewer.C.

46 {
47  std::string fn = filename(p);
48  std::size_t pos = fn.find('.');
49  if (pos == std::string::npos)
50  return fn;
51  else
52  return fn.substr(0, pos);
53 }