Add PDF writer.
This commit is contained in:
parent
c05b7b6315
commit
9c116b1efd
72 changed files with 1819 additions and 114 deletions
|
@ -1,5 +1,6 @@
|
|||
list(APPEND core_HEADERS
|
||||
AbstractApp.h
|
||||
Dictionary.h
|
||||
Event.h
|
||||
Color.h
|
||||
CommandLineArgs.h
|
||||
|
@ -12,6 +13,7 @@ list(APPEND core_HEADERS
|
|||
|
||||
list(APPEND core_LIB_INCLUDES
|
||||
Event.cpp
|
||||
Dictionary.cpp
|
||||
Color.cpp
|
||||
CommandLineArgs.cpp
|
||||
loggers/FileLogger.cpp
|
||||
|
|
56
src/core/Dictionary.cpp
Normal file
56
src/core/Dictionary.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "Dictionary.h"
|
||||
|
||||
bool Dictionary::HasKey(const std::string& key) const
|
||||
{
|
||||
return HasStringKey(key) || HasDictKey(key);
|
||||
}
|
||||
|
||||
bool Dictionary::HasStringKey(const std::string& key) const
|
||||
{
|
||||
return mStringData.count(key) > 0;
|
||||
}
|
||||
|
||||
bool Dictionary::HasDictKey(const std::string& key) const
|
||||
{
|
||||
return mDictData.count(key) > 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> Dictionary::GetStringKeys() const
|
||||
{
|
||||
std::vector<std::string> keys;
|
||||
for (const auto& item : mStringData)
|
||||
{
|
||||
keys.push_back(item.first);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
std::vector<std::string> Dictionary::GetDictKeys() const
|
||||
{
|
||||
std::vector<std::string> keys;
|
||||
for (const auto& item : mDictData)
|
||||
{
|
||||
keys.push_back(item.first);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
Dictionary* Dictionary::GetDict(const std::string& key) const
|
||||
{
|
||||
return mDictData.at(key).get();
|
||||
}
|
||||
|
||||
std::string Dictionary::GetItem(const std::string& key) const
|
||||
{
|
||||
return mStringData.at(key);
|
||||
}
|
||||
|
||||
void Dictionary::AddStringItem(const std::string& key, const std::string& item)
|
||||
{
|
||||
mStringData[key] = item;
|
||||
}
|
||||
|
||||
void Dictionary::AddDictItem(const std::string& key, std::unique_ptr<Dictionary> dict)
|
||||
{
|
||||
mDictData[key] = std::move(dict);
|
||||
}
|
35
src/core/Dictionary.h
Normal file
35
src/core/Dictionary.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
class Dictionary
|
||||
{
|
||||
public:
|
||||
Dictionary() = default;
|
||||
virtual ~Dictionary() = default;
|
||||
|
||||
bool HasKey(const std::string& key) const;
|
||||
|
||||
bool HasStringKey(const std::string& key) const;
|
||||
|
||||
bool HasDictKey(const std::string& key) const;
|
||||
|
||||
Dictionary* GetDict(const std::string& key) const;
|
||||
|
||||
std::vector<std::string> GetDictKeys() const;
|
||||
|
||||
std::vector<std::string> GetStringKeys() const;
|
||||
|
||||
std::string GetItem(const std::string& key) const;
|
||||
|
||||
void AddStringItem(const std::string& key, const std::string& item);
|
||||
|
||||
void AddDictItem(const std::string& key, std::unique_ptr<Dictionary> dict);
|
||||
|
||||
protected:
|
||||
|
||||
std::map<std::string, std::string> mStringData;
|
||||
std::map<std::string, std::unique_ptr<Dictionary> > mDictData;
|
||||
};
|
|
@ -1,6 +1,8 @@
|
|||
#include "StringUtils.h"
|
||||
#include <locale>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Windows.h"
|
||||
|
@ -45,3 +47,10 @@ std::string StringUtils::convert(const std::wstring& input)
|
|||
throw std::logic_error("Not implemented");
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string StringUtils::ToPaddedString(unsigned numBytes, unsigned entry)
|
||||
{
|
||||
std::stringstream sstr;
|
||||
sstr << std::setfill('0') << std::setw(numBytes) << entry;
|
||||
return sstr.str();
|
||||
}
|
||||
|
|
|
@ -18,4 +18,5 @@ public:
|
|||
static bool IsSpace(char c);
|
||||
static std::string ToLower(const std::string& s);
|
||||
static std::string convert(const std::wstring& input);
|
||||
static std::string ToPaddedString(unsigned numBytes, unsigned entry);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue