54 lines
956 B
C++
54 lines
956 B
C++
#include "ContentFile.h"
|
|
|
|
#include "PathUtils.h"
|
|
#include "MarkdownDocument.h"
|
|
#include "MarkdownElement.h"
|
|
|
|
ContentFile::ContentFile(const Path& filename)
|
|
: mFilename(filename)
|
|
{
|
|
|
|
}
|
|
|
|
ContentFile::~ContentFile()
|
|
{
|
|
|
|
}
|
|
|
|
Path ContentFile::getFilename() const
|
|
{
|
|
return mFilename;
|
|
}
|
|
|
|
std::string ContentFile::getOutputLocation() const
|
|
{
|
|
const auto metadata_item = getMetadataItem("save_as");
|
|
return metadata_item.empty() ? PathUtils::getBaseFilename(mFilename) : metadata_item;
|
|
}
|
|
|
|
void ContentFile::load()
|
|
{
|
|
MarkdownContentParser parser;
|
|
auto result = parser.run(mFilename);
|
|
|
|
mMetadata = result.first;
|
|
mContentBody = std::move(result.second);
|
|
}
|
|
|
|
std::string ContentFile::getMetadataItem(const std::string& key) const
|
|
{
|
|
const auto check = mMetadata.find(key);
|
|
if (check == mMetadata.end())
|
|
{
|
|
return {};
|
|
}
|
|
else
|
|
{
|
|
return check->second;
|
|
}
|
|
}
|
|
|
|
void ContentFile::write(const Path& path)
|
|
{
|
|
|
|
}
|