Start adding markdown conversion to site generator.
This commit is contained in:
parent
f0091f9e04
commit
f44c79dc1f
31 changed files with 692 additions and 461 deletions
|
@ -1,3 +1,5 @@
|
|||
set(MODULE_NAME core)
|
||||
|
||||
list(APPEND core_HEADERS
|
||||
AbstractApp.h
|
||||
Dictionary.h
|
||||
|
@ -8,6 +10,7 @@ list(APPEND core_HEADERS
|
|||
file_utilities/Directory.h
|
||||
file_utilities/File.h
|
||||
file_utilities/FileFormats.h
|
||||
file_utilities/PathUtils.h
|
||||
StringUtils.h
|
||||
http/HttpResponse.h
|
||||
serializers/TomlReader.h
|
||||
|
@ -25,6 +28,7 @@ list(APPEND core_LIB_INCLUDES
|
|||
file_utilities/Directory.cpp
|
||||
file_utilities/File.cpp
|
||||
file_utilities/FileFormats.cpp
|
||||
file_utilities/PathUtils.cpp
|
||||
memory/SharedMemory.cpp
|
||||
RandomUtils.cpp
|
||||
StringUtils.cpp
|
||||
|
@ -38,18 +42,17 @@ list(APPEND core_LIB_INCLUDES
|
|||
http/HttpRequest.cpp
|
||||
serializers/TomlReader.cpp)
|
||||
|
||||
# add the executable
|
||||
add_library(core SHARED ${core_LIB_INCLUDES} ${core_HEADERS})
|
||||
add_library(${MODULE_NAME} SHARED ${core_LIB_INCLUDES} ${core_HEADERS})
|
||||
|
||||
target_include_directories(core PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/file_utilities"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/loggers"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/memory"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/streams"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/http"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/data_structures"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/serializers"
|
||||
target_include_directories(${MODULE_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/file_utilities
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/loggers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/streams
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/http
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/data_structures
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/serializers
|
||||
)
|
||||
set_target_properties( core PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_property(TARGET core PROPERTY FOLDER src)
|
||||
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src)
|
|
@ -1,6 +1,6 @@
|
|||
#include "Directory.h"
|
||||
|
||||
std::vector<Path> Directory::getFilesWithExtension(const Path& path, const std::string& extension)
|
||||
std::vector<Path> Directory::getFilesWithExtension(const Path& path, const std::string& extension, bool recursive)
|
||||
{
|
||||
std::vector<Path> paths;
|
||||
if (std::filesystem::is_directory(path))
|
||||
|
@ -11,6 +11,11 @@ std::vector<Path> Directory::getFilesWithExtension(const Path& path, const std::
|
|||
{
|
||||
paths.push_back(entry.path());
|
||||
}
|
||||
else if(recursive && std::filesystem::is_directory(entry))
|
||||
{
|
||||
const auto child_paths = getFilesWithExtension(entry, extension, recursive);
|
||||
paths.insert(paths.end(), child_paths.begin(), child_paths.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
|
|
|
@ -9,5 +9,5 @@ class Directory
|
|||
{
|
||||
public:
|
||||
|
||||
static std::vector<Path> getFilesWithExtension(const Path& path, const std::string& extension);
|
||||
static std::vector<Path> getFilesWithExtension(const Path& path, const std::string& extension, bool recursive=false);
|
||||
};
|
||||
|
|
|
@ -197,11 +197,6 @@ std::string File::read()
|
|||
return buffer.str();
|
||||
}
|
||||
|
||||
std::string File::getBaseFilename(const Path& path)
|
||||
{
|
||||
return path.stem().string();
|
||||
}
|
||||
|
||||
std::string File::readText()
|
||||
{
|
||||
if (!pathExists())
|
||||
|
|
|
@ -20,7 +20,6 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
|
||||
File(std::filesystem::path fullPath);
|
||||
|
||||
~File();
|
||||
|
@ -29,8 +28,6 @@ public:
|
|||
|
||||
std::string dumpBinary();
|
||||
|
||||
static std::string getBaseFilename(const Path& path);
|
||||
|
||||
std::string getExtension() const;
|
||||
|
||||
std::ifstream* getInHandle() const;
|
||||
|
|
33
src/core/file_utilities/PathUtils.cpp
Normal file
33
src/core/file_utilities/PathUtils.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "PathUtils.h"
|
||||
|
||||
|
||||
std::string PathUtils::getBaseFilename(const Path& path)
|
||||
{
|
||||
return path.stem().string();
|
||||
}
|
||||
|
||||
Path PathUtils::getRelativePath(const Path& input, const Path& relativeTo)
|
||||
{
|
||||
return std::filesystem::relative(input, relativeTo);
|
||||
}
|
||||
|
||||
std::string PathUtils::getPathDelimited(const Path& path, char delimiter)
|
||||
{
|
||||
std::string name;
|
||||
|
||||
unsigned count = 0;
|
||||
for(const auto& element : path)
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
name += element.stem().string();
|
||||
}
|
||||
else
|
||||
{
|
||||
name += delimiter + element.stem().string();
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
17
src/core/file_utilities/PathUtils.h
Normal file
17
src/core/file_utilities/PathUtils.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using Path = std::filesystem::path;
|
||||
|
||||
class PathUtils
|
||||
{
|
||||
public:
|
||||
static std::string getBaseFilename(const Path& path);
|
||||
|
||||
static Path getRelativePath(const Path& path, const Path& relativeTo);
|
||||
|
||||
static std::string getPathDelimited(const Path& path, char delimiter='-');
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue