Wt examples  4.11.3
Functions
ExampleSourceViewer.C File Reference
#include "ExampleSourceViewer.h"
#include "FileItem.h"
#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/exception.hpp>
#include <boost/version.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
#include <stdlib.h>
#include <algorithm>

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 72 of file ExampleSourceViewer.C.

73 {
74  return filename(p1) > filename(p2);
75 }
static std::string filename(const fs::path &p)

◆ filename()

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

Definition at line 42 of file ExampleSourceViewer.C.

43 {
44 #if BOOST_FILESYSTEM_VERSION < 3
45  return p.empty() ? std::string() : *--p.end();
46 #else
47  return p.empty() ? std::string() : (*--p.end()).string();
48 #endif
49 }

◆ getCompanion()

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

Definition at line 192 of file ExampleSourceViewer.C.

193 {
194  std::string ext = path.extension().string();
195 
196  if (ext == ".h")
197  return parent_path(path) / (stem(path) + ".C");
198  else if (ext == ".C" || ext == ".cpp")
199  return parent_path(path) / (stem(path) + ".h");
200  else
201  return fs::path();
202 }
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 64 of file ExampleSourceViewer.C.

65 {
66  std::string fn = filename(p);
67  std::string path = p.string();
68 
69  return path.substr(0, path.length() - fn.length() - 1);
70 }

◆ stem()

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

Definition at line 52 of file ExampleSourceViewer.C.

53 {
54  std::string fn = filename(p);
55  std::size_t pos = fn.find('.');
56  if (pos == std::string::npos)
57  return fn;
58  else
59  return fn.substr(0, pos);
60 }