Wt examples  4.12.2
Loading...
Searching...
No Matches
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 <Wt/cpp17/filesystem.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 58 of file ExampleSourceViewer.C.

59{
60 return filename(p1) > filename(p2);
61}
static std::string filename(const fs::path &p)

◆ filename()

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

Definition at line 32 of file ExampleSourceViewer.C.

33{
34 return p.empty() ? std::string() : (*--p.end()).string();
35}

◆ getCompanion()

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

Definition at line 178 of file ExampleSourceViewer.C.

179{
180 std::string ext = path.extension().string();
181
182 if (ext == ".h")
183 return parent_path(path) / (stem(path) + ".C");
184 else if (ext == ".C" || ext == ".cpp")
185 return parent_path(path) / (stem(path) + ".h");
186 else
187 return fs::path();
188}
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 50 of file ExampleSourceViewer.C.

51{
52 std::string fn = filename(p);
53 std::string path = p.string();
54
55 return path.substr(0, path.length() - fn.length() - 1);
56}

◆ stem()

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

Definition at line 38 of file ExampleSourceViewer.C.

39{
40 std::string fn = filename(p);
41 std::size_t pos = fn.find('.');
42 if (pos == std::string::npos)
43 return fn;
44 else
45 return fn.substr(0, pos);
46}