/home/koen/project/wt/public-git/wt/examples/wt-homepage/ExampleSourceViewer.C File Reference

#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WEnvironment>
#include <Wt/WLineEdit>
#include <Wt/WGridLayout>
#include <Wt/WHBoxLayout>
#include <Wt/WPushButton>
#include <Wt/WTable>
#include <Wt/WText>
#include <Wt/WTreeView>
#include <Wt/WVBoxLayout>
#include <Wt/WViewWidget>
#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

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

Definition at line 62 of file ExampleSourceViewer.C.

00063 {
00064   return filename(p1) > filename(p2);
00065 }

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

Definition at line 36 of file ExampleSourceViewer.C.

00037 {
00038   return p.empty() ? std::string() : *--p.end();
00039 }

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

Definition at line 169 of file ExampleSourceViewer.C.

00170 {
00171   std::string ext = fs::extension(path);
00172 
00173   if (ext == ".h")
00174     return parent_path(path) / (stem(path) + ".C");
00175   else if (ext == ".C" || ext == ".cpp")
00176     return parent_path(path) / (stem(path) + ".h");
00177   else
00178     return fs::path();
00179 }

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

Definition at line 54 of file ExampleSourceViewer.C.

00055 {
00056   std::string fn = filename(p);
00057   std::string path = p.string();
00058 
00059   return path.substr(0, path.length() - fn.length() - 1);
00060 }

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

Definition at line 42 of file ExampleSourceViewer.C.

00043 {
00044   std::string fn = filename(p);
00045   std::size_t pos = fn.find('.');
00046   if (pos == std::string::npos)
00047     return fn;
00048   else
00049     return fn.substr(0, pos);
00050 }


Generated on Thu May 20 18:14:56 2010 for Wt by doxygen 1.5.6