Do bulk replace of stl types.
This commit is contained in:
parent
521486be62
commit
c25a56ee19
531 changed files with 2274 additions and 2181 deletions
|
@ -16,7 +16,7 @@
|
|||
#include "DesktopManager.h"
|
||||
#include "MainApplication.h"
|
||||
|
||||
NotesTk::NotesTk(std::unique_ptr<CommandLineArgs> args, std::unique_ptr<MainApplication> mainApp)
|
||||
NotesTk::NotesTk(Ptr<CommandLineArgs> args, Ptr<MainApplication> mainApp)
|
||||
: GuiApplication(std::move(args), std::move(mainApp))
|
||||
{
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
class NotesTk : public GuiApplication
|
||||
{
|
||||
public:
|
||||
NotesTk(std::unique_ptr<CommandLineArgs> args = nullptr, std::unique_ptr<MainApplication> mainApp = nullptr);
|
||||
NotesTk(Ptr<CommandLineArgs> args = nullptr, Ptr<MainApplication> mainApp = nullptr);
|
||||
|
||||
protected:
|
||||
void initializeViews() override;
|
||||
|
|
|
@ -12,7 +12,7 @@ AudioEditorView::AudioEditorView()
|
|||
addWidget(std::move(label));
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioEditorView> AudioEditorView::Create()
|
||||
Ptr<AudioEditorView> AudioEditorView::Create()
|
||||
{
|
||||
return std::make_unique<AudioEditorView>();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public:
|
|||
|
||||
AudioEditorView();
|
||||
|
||||
static std::unique_ptr<AudioEditorView> Create();
|
||||
static Ptr<AudioEditorView> Create();
|
||||
};
|
||||
|
||||
using AudioEditorViewUPtr = std::unique_ptr<AudioEditorView>;
|
||||
using AudioEditorViewUPtr = Ptr<AudioEditorView>;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "CanvasController.h"
|
||||
|
||||
std::unique_ptr<CanvasController> CanvasController::Create()
|
||||
Ptr<CanvasController> CanvasController::Create()
|
||||
{
|
||||
return std::make_unique<CanvasController>();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
class CanvasController
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<CanvasController> Create();
|
||||
static Ptr<CanvasController> Create();
|
||||
};
|
||||
|
|
|
@ -24,6 +24,6 @@ private:
|
|||
|
||||
CanvasDrawCommand mActiveDrawingCommand{CanvasDrawCommand::LINE};
|
||||
|
||||
std::vector<std::unique_ptr<GeometryNode> > mSceneNodes;
|
||||
Vector<Ptr<GeometryNode> > mSceneNodes;
|
||||
bool mContentDirty{false};
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ CanvasView::~CanvasView()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<CanvasView> CanvasView::Create()
|
||||
Ptr<CanvasView> CanvasView::Create()
|
||||
{
|
||||
return std::make_unique<CanvasView>();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void CanvasView::onDrawCommandChanged(CanvasDrawCommand command)
|
|||
mDrawingArea->setActiveDrawingCommand(command);
|
||||
}
|
||||
|
||||
std::unique_ptr<Widget> CanvasView::initializeCacheButtons()
|
||||
Ptr<Widget> CanvasView::initializeCacheButtons()
|
||||
{
|
||||
auto saveButton = Button::Create();
|
||||
saveButton->setLabel("Save");
|
||||
|
|
|
@ -13,17 +13,17 @@ public:
|
|||
|
||||
~CanvasView();
|
||||
|
||||
static std::unique_ptr<CanvasView> Create();
|
||||
static Ptr<CanvasView> Create();
|
||||
|
||||
private:
|
||||
void onDrawCommandChanged(CanvasDrawCommand command);
|
||||
|
||||
void initialize();
|
||||
|
||||
std::unique_ptr<Widget> initializeCacheButtons();
|
||||
Ptr<Widget> initializeCacheButtons();
|
||||
|
||||
std::unique_ptr<CanvasController> mController;
|
||||
Ptr<CanvasController> mController;
|
||||
|
||||
CanvasDrawingArea* mDrawingArea{nullptr};
|
||||
};
|
||||
using CanvasViewPtr = std::unique_ptr<CanvasView>;
|
||||
using CanvasViewPtr = Ptr<CanvasView>;
|
||||
|
|
|
@ -28,7 +28,7 @@ ImageEditorView::~ImageEditorView()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<ImageEditorView> ImageEditorView::Create()
|
||||
Ptr<ImageEditorView> ImageEditorView::Create()
|
||||
{
|
||||
return std::make_unique<ImageEditorView>();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public:
|
|||
|
||||
virtual ~ImageEditorView();
|
||||
|
||||
static std::unique_ptr<ImageEditorView> Create();
|
||||
static Ptr<ImageEditorView> Create();
|
||||
};
|
||||
|
||||
using ImageEditorViewUPtr = std::unique_ptr<ImageEditorView>;
|
||||
using ImageEditorViewUPtr = Ptr<ImageEditorView>;
|
||||
|
|
|
@ -16,5 +16,5 @@ private:
|
|||
unsigned mNumX{5};
|
||||
unsigned mNumY{5};
|
||||
|
||||
std::unique_ptr<GridNode> mGridNode;
|
||||
Ptr<GridNode> mGridNode;
|
||||
};
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "windows.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Vector.h"
|
||||
#include "String.h"
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
#include "NotesTk.h"
|
||||
#include "MainApplication.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
std::unique_ptr<MeshViewerView> MeshViewerView::Create()
|
||||
Ptr<MeshViewerView> MeshViewerView::Create()
|
||||
{
|
||||
return std::make_unique<MeshViewerView>();
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ class MeshViewerView : public Widget
|
|||
public:
|
||||
MeshViewerView();
|
||||
~MeshViewerView();
|
||||
static std::unique_ptr<MeshViewerView> Create();
|
||||
static Ptr<MeshViewerView> Create();
|
||||
void doPaint(const PaintEvent* event) override;
|
||||
private:
|
||||
|
||||
std::unique_ptr<AbstractMesh> mMesh;
|
||||
std::unique_ptr<MeshNode> mMeshNode;
|
||||
Ptr<AbstractMesh> mMesh;
|
||||
Ptr<MeshNode> mMeshNode;
|
||||
};
|
||||
|
|
|
@ -6,17 +6,17 @@ PlainTextDocument::PlainTextDocument()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<PlainTextDocument> PlainTextDocument::Create()
|
||||
Ptr<PlainTextDocument> PlainTextDocument::Create()
|
||||
{
|
||||
return std::make_unique<PlainTextDocument>();
|
||||
}
|
||||
|
||||
std::string PlainTextDocument::GetContent() const
|
||||
String PlainTextDocument::GetContent() const
|
||||
{
|
||||
return mContent;
|
||||
}
|
||||
|
||||
void PlainTextDocument::SetContent(const std::string& content)
|
||||
void PlainTextDocument::SetContent(const String& content)
|
||||
{
|
||||
mContent = content;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "String.h"
|
||||
#include "Memory.h"
|
||||
|
||||
class PlainTextDocument
|
||||
{
|
||||
std::string mContent;
|
||||
String mContent;
|
||||
|
||||
public:
|
||||
|
||||
PlainTextDocument();
|
||||
|
||||
static std::unique_ptr<PlainTextDocument> Create();
|
||||
static Ptr<PlainTextDocument> Create();
|
||||
|
||||
std::string GetContent() const;
|
||||
String GetContent() const;
|
||||
|
||||
void SetContent(const std::string& content);
|
||||
void SetContent(const String& content);
|
||||
|
||||
void Clear();
|
||||
|
||||
};
|
||||
|
||||
using PlainTextDocumentUPtr = std::unique_ptr<PlainTextDocument>;
|
||||
using PlainTextDocumentUPtr = Ptr<PlainTextDocument>;
|
||||
|
|
|
@ -9,17 +9,17 @@ TextEditorController::TextEditorController()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<TextEditorController> TextEditorController::Create()
|
||||
Ptr<TextEditorController> TextEditorController::Create()
|
||||
{
|
||||
return std::make_unique<TextEditorController>();
|
||||
}
|
||||
|
||||
void TextEditorController::SetContent(const std::string& content)
|
||||
void TextEditorController::SetContent(const String& content)
|
||||
{
|
||||
mModel->GetDocument()->SetContent(content);
|
||||
}
|
||||
|
||||
std::string TextEditorController::GetContent() const
|
||||
String TextEditorController::GetContent() const
|
||||
{
|
||||
return mModel->GetDocument()->GetContent();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#pragma once
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
#include <filesystem>
|
||||
#include "TextEditorModel.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@ public:
|
|||
|
||||
TextEditorController();
|
||||
|
||||
static std::unique_ptr<TextEditorController> Create();
|
||||
static Ptr<TextEditorController> Create();
|
||||
|
||||
void OnSave();
|
||||
|
||||
|
@ -17,9 +17,9 @@ public:
|
|||
|
||||
void OnLoad();
|
||||
|
||||
std::string GetContent() const;
|
||||
String GetContent() const;
|
||||
|
||||
void SetContent(const std::string& content);
|
||||
void SetContent(const String& content);
|
||||
|
||||
void SetSavePath(const std::filesystem::path& path);
|
||||
|
||||
|
@ -31,4 +31,4 @@ private:
|
|||
std::filesystem::path mLoadPath;
|
||||
};
|
||||
|
||||
using TextEditorControllerUPtr = std::unique_ptr<TextEditorController>;
|
||||
using TextEditorControllerUPtr = Ptr<TextEditorController>;
|
||||
|
|
|
@ -6,7 +6,7 @@ TextEditorModel::TextEditorModel()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<TextEditorModel> TextEditorModel::Create()
|
||||
Ptr<TextEditorModel> TextEditorModel::Create()
|
||||
{
|
||||
return std::make_unique<TextEditorModel>();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "PlainTextDocument.h"
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
class TextEditorModel
|
||||
{
|
||||
|
@ -11,9 +11,9 @@ public:
|
|||
|
||||
TextEditorModel();
|
||||
|
||||
static std::unique_ptr<TextEditorModel> Create();
|
||||
static Ptr<TextEditorModel> Create();
|
||||
|
||||
PlainTextDocument* GetDocument() const;
|
||||
};
|
||||
|
||||
using TextEditorModelUPtr = std::unique_ptr<TextEditorModel>;
|
||||
using TextEditorModelUPtr = Ptr<TextEditorModel>;
|
||||
|
|
|
@ -81,7 +81,7 @@ void TextEditorView::initialize()
|
|||
addWidget(std::move(hSpacer));
|
||||
}
|
||||
|
||||
std::unique_ptr<TextEditorView> TextEditorView::Create()
|
||||
Ptr<TextEditorView> TextEditorView::Create()
|
||||
{
|
||||
return std::make_unique<TextEditorView>();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class TextEditorView : public Widget
|
|||
public:
|
||||
TextEditorView();
|
||||
|
||||
static std::unique_ptr<TextEditorView> Create();
|
||||
static Ptr<TextEditorView> Create();
|
||||
|
||||
TextEditorController* getController();
|
||||
|
||||
|
@ -23,4 +23,4 @@ private:
|
|||
TextBox* mTextBox;
|
||||
TextEditorControllerUPtr mController;
|
||||
};
|
||||
using TextEditorViewUPtr = std::unique_ptr<TextEditorView>;
|
||||
using TextEditorViewUPtr = Ptr<TextEditorView>;
|
||||
|
|
|
@ -14,7 +14,7 @@ WebClientView::WebClientView()
|
|||
addWidget(std::move(label));
|
||||
}
|
||||
|
||||
std::unique_ptr<WebClientView> WebClientView::Create()
|
||||
Ptr<WebClientView> WebClientView::Create()
|
||||
{
|
||||
return std::make_unique<WebClientView>();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public:
|
|||
|
||||
WebClientView();
|
||||
|
||||
static std::unique_ptr<WebClientView> Create();
|
||||
static Ptr<WebClientView> Create();
|
||||
};
|
||||
|
||||
using WebClientViewUPtr = std::unique_ptr<WebClientView>;
|
||||
using WebClientViewUPtr = Ptr<WebClientView>;
|
||||
|
|
|
@ -23,7 +23,7 @@ Path ContentFile::getFilename() const
|
|||
return mFilename;
|
||||
}
|
||||
|
||||
std::string ContentFile::getOutputLocation() const
|
||||
String ContentFile::getOutputLocation() const
|
||||
{
|
||||
const auto metadata_item = getMetadataItem("save_as");
|
||||
return metadata_item.empty() ? PathUtils::getBaseFilename(mFilename) : metadata_item;
|
||||
|
@ -55,7 +55,7 @@ void ContentFile::doLinkTagSubstitution(const Path& basePath)
|
|||
}
|
||||
}
|
||||
|
||||
std::string ContentFile::getMetadataItem(const std::string& key) const
|
||||
String ContentFile::getMetadataItem(const String& key) const
|
||||
{
|
||||
const auto check = mMetadata.find(key);
|
||||
if (check == mMetadata.end())
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "MarkdownContentParser.h"
|
||||
#include "File.h"
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -12,8 +12,8 @@ class MarkdownDocument;
|
|||
class ContentFile
|
||||
{
|
||||
public:
|
||||
using FileMetadata = std::unordered_map<std::string, std::string>;
|
||||
using FileContentBody = std::vector<std::string>;
|
||||
using FileMetadata = std::unordered_map<String, String>;
|
||||
using FileContentBody = Vector<String>;
|
||||
|
||||
ContentFile(const Path& filename);
|
||||
|
||||
|
@ -23,9 +23,9 @@ public:
|
|||
|
||||
virtual void load();
|
||||
|
||||
std::string getMetadataItem(const std::string& key) const;
|
||||
String getMetadataItem(const String& key) const;
|
||||
|
||||
virtual std::string getOutputLocation() const;
|
||||
virtual String getOutputLocation() const;
|
||||
|
||||
MarkdownDocument* getContentBody() const
|
||||
{
|
||||
|
@ -36,15 +36,15 @@ public:
|
|||
|
||||
void write(const Path& path);
|
||||
|
||||
void setProcessedOutput(const std::string& output)
|
||||
void setProcessedOutput(const String& output)
|
||||
{
|
||||
mProcessedOutput = output;
|
||||
}
|
||||
protected:
|
||||
Path mFilename;
|
||||
FileMetadata mMetadata;
|
||||
std::unique_ptr<MarkdownDocument> mContentBody;
|
||||
std::string mProcessedOutput;
|
||||
Ptr<MarkdownDocument> mContentBody;
|
||||
String mProcessedOutput;
|
||||
};
|
||||
|
||||
class ContentArticle : public ContentFile
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "File.h"
|
||||
|
||||
std::pair<MarkdownContentParser::FileMetadata, std::unique_ptr<MarkdownDocument>> MarkdownContentParser::run(const Path& path)
|
||||
std::pair<MarkdownContentParser::FileMetadata, Ptr<MarkdownDocument>> MarkdownContentParser::run(const Path& path)
|
||||
{
|
||||
FileMetadata metadata;
|
||||
FileMetadata output_metadata;
|
||||
|
@ -15,7 +15,7 @@ std::pair<MarkdownContentParser::FileMetadata, std::unique_ptr<MarkdownDocument>
|
|||
const auto lines = File(path).readLines();
|
||||
bool metadata_finished = false;
|
||||
|
||||
std::string content_body;
|
||||
String content_body;
|
||||
for (const auto& line : lines)
|
||||
{
|
||||
if (!metadata_finished)
|
||||
|
@ -54,11 +54,11 @@ std::pair<MarkdownContentParser::FileMetadata, std::unique_ptr<MarkdownDocument>
|
|||
return {output_metadata, std::move(document)};
|
||||
}
|
||||
|
||||
std::optional<MarkdownContentParser::FileMetadataItem> MarkdownContentParser::checkForMetadataItem(const std::string& line) const
|
||||
std::optional<MarkdownContentParser::FileMetadataItem> MarkdownContentParser::checkForMetadataItem(const String& line) const
|
||||
{
|
||||
unsigned char_count = 0;
|
||||
std::string prefix;
|
||||
std::string suffix;
|
||||
String prefix;
|
||||
String suffix;
|
||||
bool building_prefix = true;
|
||||
for (const auto c : line)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
using Path = std::filesystem::path;
|
||||
|
||||
|
@ -13,10 +13,10 @@ class MarkdownDocument;
|
|||
class MarkdownContentParser
|
||||
{
|
||||
public:
|
||||
using FileMetadataItem = std::pair<std::string, std::string>;
|
||||
using FileMetadata = std::unordered_map<std::string, std::string>;
|
||||
using FileMetadataItem = std::pair<String, String>;
|
||||
using FileMetadata = std::unordered_map<String, String>;
|
||||
|
||||
std::pair<FileMetadata, std::unique_ptr<MarkdownDocument>> run(const Path& path);
|
||||
std::pair<FileMetadata, Ptr<MarkdownDocument>> run(const Path& path);
|
||||
private:
|
||||
std::optional<FileMetadataItem> checkForMetadataItem(const std::string& line) const;
|
||||
std::optional<FileMetadataItem> checkForMetadataItem(const String& line) const;
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ Path SiteGeneratorConfig::getThemePath() const
|
|||
return mThemesPath;
|
||||
}
|
||||
|
||||
std::string SiteGeneratorConfig::getActiveTheme() const
|
||||
String SiteGeneratorConfig::getActiveTheme() const
|
||||
{
|
||||
return mActiveTheme;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ void SiteGeneratorConfig::setThemePath(const Path& path)
|
|||
mThemesPath = path;
|
||||
}
|
||||
|
||||
void SiteGeneratorConfig::setActiveTheme(const std::string& theme)
|
||||
void SiteGeneratorConfig::setActiveTheme(const String& theme)
|
||||
{
|
||||
mActiveTheme = theme;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
#include <filesystem>
|
||||
|
||||
using Path = std::filesystem::path;
|
||||
|
@ -10,13 +10,13 @@ class SiteGeneratorConfig
|
|||
public:
|
||||
Path getThemePath() const;
|
||||
|
||||
std::string getActiveTheme() const;
|
||||
String getActiveTheme() const;
|
||||
|
||||
void setThemePath(const Path& path);
|
||||
|
||||
void setActiveTheme(const std::string& theme);
|
||||
void setActiveTheme(const String& theme);
|
||||
|
||||
private:
|
||||
Path mThemesPath;
|
||||
std::string mActiveTheme;
|
||||
String mActiveTheme;
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ WebsiteGenerator::~WebsiteGenerator()
|
|||
|
||||
}
|
||||
|
||||
void WebsiteGenerator::findProject(const std::string& searchPath)
|
||||
void WebsiteGenerator::findProject(const String& searchPath)
|
||||
{
|
||||
const auto config_path = std::filesystem::path(searchPath) / "config.toml";
|
||||
if (std::filesystem::exists(config_path))
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
using Path = std::filesystem::path;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
void doSubstitutions();
|
||||
|
||||
void findProject(const std::string& searchPath);
|
||||
void findProject(const String& searchPath);
|
||||
|
||||
void parseContentFiles();
|
||||
|
||||
|
@ -47,9 +47,9 @@ private:
|
|||
|
||||
std::filesystem::path mProjectPath;
|
||||
|
||||
std::unique_ptr<SiteGeneratorConfig> mConfig;
|
||||
std::unique_ptr<TemplatingEngine> mTemplateEngine;
|
||||
Ptr<SiteGeneratorConfig> mConfig;
|
||||
Ptr<TemplatingEngine> mTemplateEngine;
|
||||
|
||||
std::vector<std::unique_ptr<ContentPage> > mPages;
|
||||
std::vector<std::unique_ptr<ContentArticle> > mArticles;
|
||||
Vector<Ptr<ContentPage> > mPages;
|
||||
Vector<Ptr<ContentArticle> > mArticles;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "String.h"
|
||||
#include "Memory.h"
|
||||
|
||||
|
||||
class CircuitElement
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "Memory.h"
|
||||
#include "Vector.h"
|
||||
|
||||
#include "CircuitElement.h"
|
||||
#include "LogicGate.h"
|
||||
#include "Terminal.h"
|
||||
|
||||
using LogicGatePtr = std::unique_ptr<LogicGate>;
|
||||
using LogicGatePtr = Ptr<LogicGate>;
|
||||
|
||||
class ElectronicCircuit
|
||||
{
|
||||
|
@ -20,33 +20,33 @@ public:
|
|||
|
||||
void addLogicGate(LogicGatePtr gate);
|
||||
|
||||
const std::vector<Terminal*>& getInputTerminals() const
|
||||
const Vector<Terminal*>& getInputTerminals() const
|
||||
{
|
||||
return mInputTerminals;
|
||||
}
|
||||
|
||||
const std::vector<Terminal*>& getOutputTerminals() const
|
||||
const Vector<Terminal*>& getOutputTerminals() const
|
||||
{
|
||||
return mOutputTerminals;
|
||||
}
|
||||
|
||||
const std::vector<LogicGate*>& getLogicGates() const
|
||||
const Vector<LogicGate*>& getLogicGates() const
|
||||
{
|
||||
return mLogicGates;
|
||||
}
|
||||
|
||||
const std::vector<Wire*>& getWires() const
|
||||
const Vector<Wire*>& getWires() const
|
||||
{
|
||||
return mWires;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Terminal*> mInputTerminals;
|
||||
std::vector<Terminal*> mOutputTerminals;
|
||||
Vector<Terminal*> mInputTerminals;
|
||||
Vector<Terminal*> mOutputTerminals;
|
||||
|
||||
std::vector<Wire*> mWires;
|
||||
Vector<Wire*> mWires;
|
||||
|
||||
std::vector<LogicGate*> mLogicGates;
|
||||
Vector<LogicGate*> mLogicGates;
|
||||
|
||||
std::vector<std::unique_ptr<CircuitElement> > mElements;
|
||||
Vector<Ptr<CircuitElement> > mElements;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Terminal.h"
|
||||
|
||||
Terminal::Terminal(TerminalType type, const std::string& label)
|
||||
Terminal::Terminal(TerminalType type, const String& label)
|
||||
: mLabel(label),
|
||||
mType(type)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "CircuitElement.h"
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
class Wire;
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
|||
OUTPUT
|
||||
};
|
||||
|
||||
Terminal(TerminalType type, const std::string& label = {});
|
||||
Terminal(TerminalType type, const String& label = {});
|
||||
|
||||
Wire* getConnection() const;
|
||||
|
||||
|
@ -27,8 +27,8 @@ public:
|
|||
void setConnection(Wire* connection);
|
||||
|
||||
private:
|
||||
std::string mLabel;
|
||||
String mLabel;
|
||||
TerminalType mType;
|
||||
Wire* mConnection{ nullptr };
|
||||
};
|
||||
using TerminalPtr = std::unique_ptr<Terminal>;
|
||||
using TerminalPtr = Ptr<Terminal>;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
class TruthTable
|
||||
{
|
||||
public:
|
||||
using TableData = std::map<std::vector<bool>, std::vector<bool> >;
|
||||
using TableData = std::map<Vector<bool>, Vector<bool> >;
|
||||
|
||||
TruthTable(std::size_t, std::size_t)
|
||||
//: mNumInputColumns(numInputColumns),
|
||||
|
|
|
@ -18,7 +18,7 @@ private:
|
|||
CircuitElement* mInput{ nullptr };
|
||||
CircuitElement* mOutput{ nullptr };
|
||||
};
|
||||
using WirePtr = std::unique_ptr<Wire>;
|
||||
using WirePtr = Ptr<Wire>;
|
||||
|
||||
class Fanout : public CircuitElement
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "LogicGate.h"
|
||||
|
||||
NInMOutLogicGate::NInMOutLogicGate(std::size_t numIn, std::size_t numOut, std::vector<Wire*> inputs, std::vector<Wire*> outputs)
|
||||
NInMOutLogicGate::NInMOutLogicGate(std::size_t numIn, std::size_t numOut, Vector<Wire*> inputs, Vector<Wire*> outputs)
|
||||
: LogicGate(),
|
||||
mNumIn(numIn),
|
||||
mNumOut(numOut)
|
||||
|
@ -11,7 +11,7 @@ NInMOutLogicGate::NInMOutLogicGate(std::size_t numIn, std::size_t numOut, std::v
|
|||
}
|
||||
else
|
||||
{
|
||||
mInputs = std::vector<Wire*>(numIn, nullptr);
|
||||
mInputs = Vector<Wire*>(numIn, nullptr);
|
||||
}
|
||||
|
||||
if (outputs.size() == mNumOut)
|
||||
|
@ -20,7 +20,7 @@ NInMOutLogicGate::NInMOutLogicGate(std::size_t numIn, std::size_t numOut, std::v
|
|||
}
|
||||
else
|
||||
{
|
||||
mOutputs = std::vector<Wire*>(numOut, nullptr);
|
||||
mOutputs = Vector<Wire*>(numOut, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "TruthTable.h"
|
||||
#include "Wire.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "Memory.h"
|
||||
#include "Vector.h"
|
||||
|
||||
class LogicGate : public CircuitElement
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
class NInMOutLogicGate : public LogicGate
|
||||
{
|
||||
public:
|
||||
NInMOutLogicGate(std::size_t numIn, std::size_t numOut, std::vector<Wire*> inputs = {}, std::vector<Wire*> outputs = {});
|
||||
NInMOutLogicGate(std::size_t numIn, std::size_t numOut, Vector<Wire*> inputs = {}, Vector<Wire*> outputs = {});
|
||||
|
||||
virtual ~NInMOutLogicGate() = default;
|
||||
|
||||
|
@ -61,8 +61,8 @@ private:
|
|||
std::size_t mNumIn{ 1 };
|
||||
std::size_t mNumOut{ 1 };
|
||||
|
||||
std::vector<Wire*> mInputs;
|
||||
std::vector<Wire*> mOutputs;
|
||||
Vector<Wire*> mInputs;
|
||||
Vector<Wire*> mOutputs;
|
||||
};
|
||||
|
||||
class TwoInOneOutLogicGate : public NInMOutLogicGate
|
||||
|
|
|
@ -31,10 +31,10 @@ private:
|
|||
ElectronicCircuit* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::vector<std::unique_ptr<TerminalNode> > mInputTerminalNodes;
|
||||
std::vector<std::unique_ptr<TerminalNode> > mOutputTerminalNodes;
|
||||
std::vector<std::unique_ptr<WireNode> > mWireNodes;
|
||||
std::vector<std::unique_ptr<LogicGateNode> > mLogicGateNodes;
|
||||
Vector<Ptr<TerminalNode> > mInputTerminalNodes;
|
||||
Vector<Ptr<TerminalNode> > mOutputTerminalNodes;
|
||||
Vector<Ptr<WireNode> > mWireNodes;
|
||||
Vector<Ptr<LogicGateNode> > mLogicGateNodes;
|
||||
|
||||
std::unordered_map<Wire*, CircuitElement*> mWireInputConnections;
|
||||
std::unordered_map<Wire*, CircuitElement*> mWireOutputConnections;
|
||||
|
|
|
@ -25,6 +25,6 @@ private:
|
|||
LogicGate* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::unique_ptr<PathNode> mPrimaryPath;
|
||||
std::unique_ptr<CircleNode> mNegationGlyph;
|
||||
Ptr<PathNode> mPrimaryPath;
|
||||
Ptr<CircleNode> mNegationGlyph;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "LogicGatePrimitiveShapes.h"
|
||||
|
||||
std::string LogicGatePrimitiveShapes::getAndGateShape()
|
||||
String LogicGatePrimitiveShapes::getAndGateShape()
|
||||
{
|
||||
return "M4 8 h24 a16 16 0 0 1 0 32 h-24Z";
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ Point2 LogicGatePrimitiveShapes::getAndGateConnectionLocation(bool isInput, std:
|
|||
}
|
||||
}
|
||||
|
||||
std::string LogicGatePrimitiveShapes::getOrGateShape()
|
||||
String LogicGatePrimitiveShapes::getOrGateShape()
|
||||
{
|
||||
return "M4 8 h16 q16 2 24 16 q-12 16 -24 16 h-16 q12 -16 0 -32Z";
|
||||
}
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
#include "Point.h"
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
class LogicGatePrimitiveShapes
|
||||
{
|
||||
public:
|
||||
static Point2 getAndGateConnectionLocation(bool isInput, std::size_t idx);
|
||||
|
||||
static std::string getAndGateShape();
|
||||
static String getAndGateShape();
|
||||
|
||||
static Point2 getOrGateConnectionLocation(bool isInput, std::size_t idx);
|
||||
|
||||
static std::string getOrGateShape();
|
||||
static String getOrGateShape();
|
||||
};
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
std::unique_ptr<CircleNode> mMarker;
|
||||
Ptr<CircleNode> mMarker;
|
||||
|
||||
Terminal* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
|
|
@ -48,7 +48,7 @@ void WireNode::createOrUpdateGeometry(SceneInfo*)
|
|||
auto loc = mOutputLocation;
|
||||
loc.moveBy(-mInputLocation.getX(), -mInputLocation.getY(), -mInputLocation.getZ());
|
||||
|
||||
std::vector<Point2> points;
|
||||
Vector<Point2> points;
|
||||
|
||||
if (loc.getY() == 0.0)
|
||||
{
|
||||
|
|
|
@ -26,5 +26,5 @@ private:
|
|||
Point2 mInputLocation;
|
||||
Point2 mOutputLocation;
|
||||
|
||||
std::unique_ptr<LineNode> mLine;
|
||||
Ptr<LineNode> mLine;
|
||||
};
|
|
@ -9,7 +9,7 @@ MetaMidiEvent::MetaMidiEvent()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<MetaMidiEvent> MetaMidiEvent::Create()
|
||||
Ptr<MetaMidiEvent> MetaMidiEvent::Create()
|
||||
{
|
||||
return std::make_unique<MetaMidiEvent>();
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void MetaMidiEvent::SetValue(int value)
|
|||
mValue = value;
|
||||
}
|
||||
|
||||
void MetaMidiEvent::SetLabel(const std::string& label)
|
||||
void MetaMidiEvent::SetLabel(const String& label)
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "MidiEvent.h"
|
||||
#include "MidiElements.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Memory.h"
|
||||
#include "String.h"
|
||||
|
||||
class MetaMidiEvent : public MidiEvent
|
||||
{
|
||||
|
@ -51,13 +51,13 @@ private:
|
|||
public:
|
||||
|
||||
MetaMidiEvent();
|
||||
static std::unique_ptr<MetaMidiEvent> Create();
|
||||
static Ptr<MetaMidiEvent> Create();
|
||||
|
||||
void SetValue(int value);
|
||||
void SetType(char c);
|
||||
Type GetType() const;
|
||||
|
||||
void SetLabel(const std::string& label);
|
||||
void SetLabel(const String& label);
|
||||
void SetTimeSignature(const MidiTimeSignature& timeSig);
|
||||
void SetTimeCode(const MidiSmtpeTimecode& timeCode);
|
||||
void SetKeySignature(const MidiKeySignature& keySig);
|
||||
|
@ -65,11 +65,11 @@ public:
|
|||
private:
|
||||
Type mType {Type::UNSET};
|
||||
char mUnKnownMarker{0};
|
||||
std::string mLabel;
|
||||
String mLabel;
|
||||
int mValue { 0 };
|
||||
MidiTimeSignature mTimeSig;
|
||||
MidiSmtpeTimecode mTimecode;
|
||||
MidiKeySignature mKeySig;
|
||||
};
|
||||
|
||||
using MetaMidiEventPtr = std::unique_ptr<MetaMidiEvent>;
|
||||
using MetaMidiEventPtr = Ptr<MetaMidiEvent>;
|
||||
|
|
|
@ -9,7 +9,7 @@ MidiChannelEvent::MidiChannelEvent()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<MidiChannelEvent> MidiChannelEvent::Create()
|
||||
Ptr<MidiChannelEvent> MidiChannelEvent::Create()
|
||||
{
|
||||
return std::make_unique<MidiChannelEvent>();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "MidiEvent.h"
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
class MidiChannelEvent : public MidiEvent
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
public:
|
||||
MidiChannelEvent();
|
||||
static std::unique_ptr<MidiChannelEvent> Create();
|
||||
static Ptr<MidiChannelEvent> Create();
|
||||
|
||||
void SetTypeAndChannel(char c);
|
||||
void SetType(Type type);
|
||||
|
@ -69,4 +69,4 @@ private:
|
|||
int mValue1 {1};
|
||||
};
|
||||
|
||||
using MidiChannelEventPtr = std::unique_ptr<MidiChannelEvent>;
|
||||
using MidiChannelEventPtr = Ptr<MidiChannelEvent>;
|
||||
|
|
|
@ -7,7 +7,7 @@ MidiDocument::MidiDocument()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<MidiDocument> MidiDocument::Create()
|
||||
Ptr<MidiDocument> MidiDocument::Create()
|
||||
{
|
||||
return std::make_unique<MidiDocument>();
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ void MidiDocument::SetTimeDivision(const MidiTimeDivision& timeDivision)
|
|||
mTimeDivision = timeDivision;
|
||||
}
|
||||
|
||||
std::string MidiDocument::Serialize() const
|
||||
String MidiDocument::Serialize() const
|
||||
{
|
||||
std::string output = "MidiDocument\n";
|
||||
String output = "MidiDocument\n";
|
||||
output += "Format type: " + std::to_string(mFormatType) + "\n";
|
||||
output += "Expected Tracks: " + std::to_string(mExpectedTracks) + "\n";
|
||||
output += "Use fps: " + std::to_string(mTimeDivision.mUseFps) + "\n";
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Vector.h"
|
||||
#include "Memory.h"
|
||||
#include "String.h"
|
||||
|
||||
#include "MidiElements.h"
|
||||
|
||||
class MidiTrack;
|
||||
using MidiTrackPtr = std::unique_ptr<MidiTrack>;
|
||||
using MidiTrackPtr = Ptr<MidiTrack>;
|
||||
|
||||
class MidiDocument
|
||||
{
|
||||
public:
|
||||
MidiDocument();
|
||||
|
||||
static std::unique_ptr<MidiDocument> Create();
|
||||
static Ptr<MidiDocument> Create();
|
||||
|
||||
void AddTrack(MidiTrackPtr track);
|
||||
|
||||
|
@ -22,13 +22,13 @@ public:
|
|||
void SetExpectedTracks(int expected);
|
||||
void SetTimeDivision(const MidiTimeDivision& timeDivision);
|
||||
|
||||
std::string Serialize() const;
|
||||
String Serialize() const;
|
||||
|
||||
private:
|
||||
int mFormatType = 0;
|
||||
int mExpectedTracks = 0;
|
||||
MidiTimeDivision mTimeDivision;
|
||||
std::vector<MidiTrackPtr> mTracks;
|
||||
Vector<MidiTrackPtr> mTracks;
|
||||
};
|
||||
|
||||
using MidiDocumentPtr = std::unique_ptr<MidiDocument>;
|
||||
using MidiDocumentPtr = Ptr<MidiDocument>;
|
||||
|
|
|
@ -6,7 +6,7 @@ MidiEvent::MidiEvent()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<MidiEvent> MidiEvent::Create()
|
||||
Ptr<MidiEvent> MidiEvent::Create()
|
||||
{
|
||||
return std::make_unique<MidiEvent>();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
class MidiEvent
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ public:
|
|||
MidiEvent();
|
||||
virtual ~MidiEvent() = default;
|
||||
|
||||
static std::unique_ptr<MidiEvent> Create();
|
||||
static Ptr<MidiEvent> Create();
|
||||
|
||||
void SetTimeDelta(int delta);
|
||||
|
||||
|
@ -26,4 +26,4 @@ private:
|
|||
int mTimeDelta{0};
|
||||
};
|
||||
|
||||
using MidiEventPtr = std::unique_ptr<MidiEvent>;
|
||||
using MidiEventPtr = Ptr<MidiEvent>;
|
||||
|
|
|
@ -27,9 +27,9 @@ std::size_t MidiTrack::GetNumEvents()
|
|||
return mEvents.size();
|
||||
}
|
||||
|
||||
std::string MidiTrack::Serialize() const
|
||||
String MidiTrack::Serialize() const
|
||||
{
|
||||
std::string output = "MidiTrack\n";
|
||||
String output = "MidiTrack\n";
|
||||
output += "Num Events: " + std::to_string(mEvents.size()) + "\n";
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Vector.h"
|
||||
#include "Memory.h"
|
||||
#include "String.h"
|
||||
#include "MidiEvent.h"
|
||||
|
||||
class MidiEvent;
|
||||
using MidiEventPtr = std::unique_ptr<MidiEvent>;
|
||||
using MidiEventPtr = Ptr<MidiEvent>;
|
||||
|
||||
class MidiTrack
|
||||
{
|
||||
|
@ -22,9 +22,9 @@ public:
|
|||
|
||||
std::size_t GetNumEvents();
|
||||
|
||||
std::string Serialize() const;
|
||||
String Serialize() const;
|
||||
|
||||
private:
|
||||
|
||||
std::vector<MidiEventPtr> mEvents;
|
||||
Vector<MidiEventPtr> mEvents;
|
||||
};
|
||||
|
|
|
@ -83,7 +83,7 @@ int MidiMetaEventAdapter::ReadStringEvent(std::ifstream* file, MetaMidiEvent* ev
|
|||
int length = *BinaryStream::getNextByteAsInt(file);
|
||||
byteCount++;
|
||||
|
||||
std::string name;
|
||||
String name;
|
||||
BinaryStream::getNextString(file, name, length);
|
||||
byteCount += length;
|
||||
event->SetLabel(name);
|
||||
|
@ -104,7 +104,7 @@ int MidiMetaEventAdapter::ReadIntEvent(std::ifstream* file, MetaMidiEvent* event
|
|||
byteCount ++;
|
||||
}
|
||||
|
||||
std::string buffer;
|
||||
String buffer;
|
||||
BinaryStream::getNextNBytes(file, buffer.data(), length);
|
||||
byteCount += length;
|
||||
|
||||
|
@ -119,7 +119,7 @@ int MidiMetaEventAdapter::ReadChannelPrefixEvent(std::ifstream* file, MetaMidiEv
|
|||
int length = *BinaryStream::getNextByteAsInt(file);
|
||||
byteCount ++;
|
||||
|
||||
std::string buffer;
|
||||
String buffer;
|
||||
BinaryStream::getNextNBytes(file, buffer.data(), length);
|
||||
byteCount += length;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "File.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
using Path = std::filesystem::path;
|
||||
|
||||
|
@ -29,7 +29,7 @@ private:
|
|||
int processEvent(MidiTrack* track);
|
||||
|
||||
private:
|
||||
std::unique_ptr<File> mFile;
|
||||
Ptr<File> mFile;
|
||||
MidiDocumentPtr mDocument;
|
||||
int mLastMidiChannel {0};
|
||||
MidiChannelEvent::Type mLastChannelEventType;
|
||||
|
|
|
@ -28,22 +28,22 @@ void QuantumCircuit::addLogicGate(QuantumGatePtr gate)
|
|||
mElements.push_back(std::move(gate));
|
||||
}
|
||||
|
||||
const std::vector<QuantumTerminal*>& QuantumCircuit::getInputTerminals() const
|
||||
const Vector<QuantumTerminal*>& QuantumCircuit::getInputTerminals() const
|
||||
{
|
||||
return mInputTerminals;
|
||||
}
|
||||
|
||||
const std::vector<QuantumTerminal*>& QuantumCircuit::getOutputTerminals() const
|
||||
const Vector<QuantumTerminal*>& QuantumCircuit::getOutputTerminals() const
|
||||
{
|
||||
return mOutputTerminals;
|
||||
}
|
||||
|
||||
const std::vector<QuantumGate*>& QuantumCircuit::getLogicGates() const
|
||||
const Vector<QuantumGate*>& QuantumCircuit::getLogicGates() const
|
||||
{
|
||||
return mGates;
|
||||
}
|
||||
|
||||
const std::vector<QuantumWire*>& QuantumCircuit::getQuantumWires() const
|
||||
const Vector<QuantumWire*>& QuantumCircuit::getQuantumWires() const
|
||||
{
|
||||
return mWires;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "QuantumWire.h"
|
||||
#include "QuantumState.h"
|
||||
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
class QuantumCircuit
|
||||
{
|
||||
|
@ -21,24 +21,24 @@ public:
|
|||
|
||||
void buildWireConnections();
|
||||
|
||||
const std::vector<QuantumTerminal*>& getInputTerminals() const;
|
||||
const Vector<QuantumTerminal*>& getInputTerminals() const;
|
||||
|
||||
const std::vector<QuantumTerminal*>& getOutputTerminals() const;
|
||||
const Vector<QuantumTerminal*>& getOutputTerminals() const;
|
||||
|
||||
const std::vector<QuantumGate*>& getLogicGates() const;
|
||||
const Vector<QuantumGate*>& getLogicGates() const;
|
||||
|
||||
const std::vector<QuantumWire*>& getQuantumWires() const;
|
||||
const Vector<QuantumWire*>& getQuantumWires() const;
|
||||
|
||||
QuantumState getInputState() const;
|
||||
|
||||
private:
|
||||
bool connectivityIsValid() const;
|
||||
|
||||
std::vector<QuantumTerminal*> mInputTerminals;
|
||||
std::vector<QuantumTerminal*> mOutputTerminals;
|
||||
Vector<QuantumTerminal*> mInputTerminals;
|
||||
Vector<QuantumTerminal*> mOutputTerminals;
|
||||
|
||||
std::vector<QuantumWire*> mWires;
|
||||
std::vector<QuantumGate*> mGates;
|
||||
Vector<QuantumWire*> mWires;
|
||||
Vector<QuantumGate*> mGates;
|
||||
|
||||
std::vector<std::unique_ptr<QuantumCircuitElement> > mElements;
|
||||
Vector<Ptr<QuantumCircuitElement> > mElements;
|
||||
};
|
|
@ -10,13 +10,13 @@
|
|||
#include "StringUtils.h"
|
||||
#include "FileLogger.h"
|
||||
|
||||
std::unique_ptr<QuantumCircuit> QuantumCircuitReader::read(const Path& path)
|
||||
Ptr<QuantumCircuit> QuantumCircuitReader::read(const Path& path)
|
||||
{
|
||||
File file(path);
|
||||
return read(file.readText());
|
||||
}
|
||||
|
||||
std::unique_ptr<QuantumCircuit> QuantumCircuitReader::read(const std::string& content)
|
||||
Ptr<QuantumCircuit> QuantumCircuitReader::read(const String& content)
|
||||
{
|
||||
auto circuit = std::make_unique<QuantumCircuit>();
|
||||
mWorkingCircuit = circuit.get();
|
||||
|
@ -31,7 +31,7 @@ std::unique_ptr<QuantumCircuit> QuantumCircuitReader::read(const std::string& co
|
|||
return circuit;
|
||||
}
|
||||
|
||||
void QuantumCircuitReader::onLine(const std::string& line, std::size_t jdx)
|
||||
void QuantumCircuitReader::onLine(const String& line, std::size_t jdx)
|
||||
{
|
||||
mWorkingString.clear();
|
||||
std::size_t cursor = 0;
|
||||
|
@ -39,7 +39,7 @@ void QuantumCircuitReader::onLine(const std::string& line, std::size_t jdx)
|
|||
while (cursor < line.size())
|
||||
{
|
||||
const auto c = line[cursor];
|
||||
MLOG_INFO("Working char: " << std::string(1, c));
|
||||
MLOG_INFO("Working char: " << String(1, c));
|
||||
|
||||
if (c == '|')
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ void QuantumCircuitReader::onLineEnd()
|
|||
mWorkingElement = nullptr;
|
||||
}
|
||||
|
||||
void QuantumCircuitReader::onGate(Location, const std::string value)
|
||||
void QuantumCircuitReader::onGate(Location, const String value)
|
||||
{
|
||||
MLOG_INFO("Got gate: " << value);
|
||||
|
||||
|
@ -128,9 +128,9 @@ void QuantumCircuitReader::onGate(Location, const std::string value)
|
|||
}
|
||||
}
|
||||
|
||||
std::string QuantumCircuitReader::checkForGate(const std::string& segment)
|
||||
String QuantumCircuitReader::checkForGate(const String& segment)
|
||||
{
|
||||
std::string working_string;
|
||||
String working_string;
|
||||
for (const auto c : segment)
|
||||
{
|
||||
if (c == '-')
|
||||
|
@ -142,7 +142,7 @@ std::string QuantumCircuitReader::checkForGate(const std::string& segment)
|
|||
return working_string;
|
||||
}
|
||||
|
||||
void QuantumCircuitReader::onKet(Location, const std::string value)
|
||||
void QuantumCircuitReader::onKet(Location, const String value)
|
||||
{
|
||||
MLOG_INFO("Got input state: " << value);
|
||||
Qubit qubit;
|
||||
|
@ -157,7 +157,7 @@ void QuantumCircuitReader::onKet(Location, const std::string value)
|
|||
mWorkingCircuit->addInputTerminal(std::move(input_terminal));
|
||||
}
|
||||
|
||||
std::size_t QuantumCircuitReader::getWireEnd(const std::string& segment)
|
||||
std::size_t QuantumCircuitReader::getWireEnd(const String& segment)
|
||||
{
|
||||
std::size_t idx = 0;
|
||||
for (const auto c : segment)
|
||||
|
@ -171,9 +171,9 @@ std::size_t QuantumCircuitReader::getWireEnd(const std::string& segment)
|
|||
return idx;
|
||||
}
|
||||
|
||||
std::string QuantumCircuitReader::checkForKet(const std::string& segment)
|
||||
String QuantumCircuitReader::checkForKet(const String& segment)
|
||||
{
|
||||
std::string working_string;
|
||||
String working_string;
|
||||
bool found{ false };
|
||||
|
||||
for (const auto c : segment)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
using Path = std::filesystem::path;
|
||||
|
||||
|
@ -11,30 +11,30 @@ class QuantumCircuitElement;
|
|||
class QuantumCircuitReader
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<QuantumCircuit> read(const Path& path);
|
||||
Ptr<QuantumCircuit> read(const Path& path);
|
||||
|
||||
std::unique_ptr<QuantumCircuit> read(const std::string& content);
|
||||
Ptr<QuantumCircuit> read(const String& content);
|
||||
|
||||
private:
|
||||
using Location = std::pair<std::size_t, std::size_t>;
|
||||
|
||||
void onLine(const std::string& line, std::size_t jdx);
|
||||
void onLine(const String& line, std::size_t jdx);
|
||||
|
||||
std::string checkForKet(const std::string& segment);
|
||||
String checkForKet(const String& segment);
|
||||
|
||||
std::string checkForGate(const std::string& segment);
|
||||
String checkForGate(const String& segment);
|
||||
|
||||
std::size_t getWireEnd(const std::string& segment);
|
||||
std::size_t getWireEnd(const String& segment);
|
||||
|
||||
void onGate(Location loc, const std::string value);
|
||||
void onGate(Location loc, const String value);
|
||||
|
||||
void onKet(Location loc, const std::string value);
|
||||
void onKet(Location loc, const String value);
|
||||
|
||||
void onLineEnd();
|
||||
|
||||
void onVertialQuantumWire(Location loc);
|
||||
|
||||
std::string mWorkingString;
|
||||
String mWorkingString;
|
||||
QuantumCircuitElement* mWorkingElement{ nullptr };
|
||||
QuantumCircuit* mWorkingCircuit{ nullptr };
|
||||
};
|
|
@ -1,13 +1,13 @@
|
|||
#include "QuantumState.h"
|
||||
|
||||
const std::vector<Qubit>& QuantumState::getData() const
|
||||
const Vector<Qubit>& QuantumState::getData() const
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
std::string QuantumState::toString() const
|
||||
String QuantumState::toString() const
|
||||
{
|
||||
std::string out;
|
||||
String out;
|
||||
for (const auto& qubit : mState)
|
||||
{
|
||||
out += "|" + qubit.toString() + "\n";
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "Qubit.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Vector.h"
|
||||
#include "String.h"
|
||||
|
||||
class QuantumState
|
||||
{
|
||||
|
@ -13,10 +13,10 @@ public:
|
|||
mState.push_back(data);
|
||||
}
|
||||
|
||||
const std::vector<Qubit>& getData() const;
|
||||
const Vector<Qubit>& getData() const;
|
||||
|
||||
std::string toString() const;
|
||||
String toString() const;
|
||||
|
||||
private:
|
||||
std::vector<Qubit> mState;
|
||||
Vector<Qubit> mState;
|
||||
};
|
||||
|
|
|
@ -29,9 +29,9 @@ bool Qubit::isIn1State() const
|
|||
return mBeta.getReal() == 1.0 && mAlpha.getMagnitude() == 0.0;
|
||||
}
|
||||
|
||||
std::string Qubit::toString(std::size_t precision) const
|
||||
String Qubit::toString(std::size_t precision) const
|
||||
{
|
||||
std::stringstream sstr;
|
||||
Stringstream sstr;
|
||||
sstr.precision(precision);
|
||||
sstr << "alpha " << mAlpha.getReal() << " " << mAlpha.getImaginary() << "i , beta " << mBeta.getReal() << " " << mBeta.getImaginary() << "i";
|
||||
return sstr.str();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "ComplexNumber.h"
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
class Qubit
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
bool isIn1State() const;
|
||||
|
||||
std::string toString(std::size_t precision=3) const;
|
||||
String toString(std::size_t precision=3) const;
|
||||
private:
|
||||
ComplexNumber mAlpha;
|
||||
ComplexNumber mBeta;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
class QuantumCircuitElement
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "QuantumGate.h"
|
||||
|
||||
NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, std::vector<AbstractQuantumWire*> inputs, std::vector<AbstractQuantumWire*> outputs)
|
||||
NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, Vector<AbstractQuantumWire*> inputs, Vector<AbstractQuantumWire*> outputs)
|
||||
: QuantumGate(),
|
||||
mNumIn(numIn),
|
||||
mNumOut(numOut)
|
||||
|
@ -11,7 +11,7 @@ NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, st
|
|||
}
|
||||
else
|
||||
{
|
||||
mInputs = std::vector<AbstractQuantumWire*>(numIn, nullptr);
|
||||
mInputs = Vector<AbstractQuantumWire*>(numIn, nullptr);
|
||||
}
|
||||
|
||||
if (outputs.size() == mNumOut)
|
||||
|
@ -20,7 +20,7 @@ NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, st
|
|||
}
|
||||
else
|
||||
{
|
||||
mOutputs = std::vector<AbstractQuantumWire*>(numOut, nullptr);
|
||||
mOutputs = Vector<AbstractQuantumWire*>(numOut, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "QuantumWire.h"
|
||||
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
class QuantumGate : public QuantumCircuitElement
|
||||
{
|
||||
|
@ -39,13 +39,13 @@ public:
|
|||
return Type::GATE;
|
||||
}
|
||||
};
|
||||
using QuantumGatePtr = std::unique_ptr<QuantumGate>;
|
||||
using QuantumGatePtr = Ptr<QuantumGate>;
|
||||
|
||||
|
||||
class NInMOutQuantumGate : public QuantumGate
|
||||
{
|
||||
public:
|
||||
NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, std::vector<AbstractQuantumWire*> inputs = {}, std::vector<AbstractQuantumWire*> outputs = {});
|
||||
NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, Vector<AbstractQuantumWire*> inputs = {}, Vector<AbstractQuantumWire*> outputs = {});
|
||||
|
||||
virtual ~NInMOutQuantumGate() = default;
|
||||
|
||||
|
@ -85,8 +85,8 @@ private:
|
|||
std::size_t mNumIn{ 1 };
|
||||
std::size_t mNumOut{ 1 };
|
||||
|
||||
std::vector<AbstractQuantumWire*> mInputs;
|
||||
std::vector<AbstractQuantumWire*> mOutputs;
|
||||
Vector<AbstractQuantumWire*> mInputs;
|
||||
Vector<AbstractQuantumWire*> mOutputs;
|
||||
};
|
||||
|
||||
class TwoInOneOutQuantumGate : public NInMOutQuantumGate
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "QuantumTerminal.h"
|
||||
|
||||
QuantumTerminal::QuantumTerminal(TerminalType type, const std::string& label)
|
||||
QuantumTerminal::QuantumTerminal(TerminalType type, const String& label)
|
||||
: mLabel(label),
|
||||
mType(type)
|
||||
{
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include "QuantumCircuitElement.h"
|
||||
#include "Qubit.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "String.h"
|
||||
#include "Memory.h"
|
||||
|
||||
class QuantumWire;
|
||||
|
||||
|
@ -17,7 +17,7 @@ public:
|
|||
OUTPUT
|
||||
};
|
||||
|
||||
QuantumTerminal(TerminalType type, const std::string& label = {});
|
||||
QuantumTerminal(TerminalType type, const String& label = {});
|
||||
|
||||
QuantumWire* getConnection() const;
|
||||
|
||||
|
@ -40,9 +40,9 @@ public:
|
|||
void setValue(const Qubit& value);
|
||||
|
||||
private:
|
||||
std::string mLabel;
|
||||
String mLabel;
|
||||
TerminalType mType;
|
||||
Qubit mValue;
|
||||
QuantumWire* mConnection{ nullptr };
|
||||
};
|
||||
using QuantumTerminalPtr = std::unique_ptr<QuantumTerminal>;
|
||||
using QuantumTerminalPtr = Ptr<QuantumTerminal>;
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
Type getType() const override;
|
||||
WireType getWireType() const override;
|
||||
};
|
||||
using QuantumWirePtr = std::unique_ptr<QuantumWire>;
|
||||
using QuantumWirePtr = Ptr<QuantumWire>;
|
||||
|
||||
class ClassicalWire : public AbstractQuantumWire
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ void BlochSphereNode::update(SceneInfo*)
|
|||
mOuterCircle = std::make_unique<CircleNode>(loc, mSize/2.0);
|
||||
|
||||
const auto end_point_x = Point2(loc.getX() + 1.2 * mSize / 2.0, loc.getY());
|
||||
const std::vector<Point2> points{end_point_x };
|
||||
const Vector<Point2> points{end_point_x };
|
||||
mXAxis = std::make_unique<LineNode>(loc, points);
|
||||
|
||||
mCentreCircle = std::make_unique<CircleNode>(loc, mSize / 50.0);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "AbstractVisualNode.h"
|
||||
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
class BlochSphere;
|
||||
class CircleNode;
|
||||
|
@ -23,12 +23,12 @@ private:
|
|||
bool mContentDirty{ true };
|
||||
BlochSphere* mContent{ nullptr };
|
||||
|
||||
std::unique_ptr<CircleNode> mOuterCircle;
|
||||
std::unique_ptr<CircleNode> mInnerCircle;
|
||||
std::unique_ptr<CircleNode> mCentreCircle;
|
||||
std::unique_ptr<CircleNode> mStateMarkerCircle;
|
||||
std::unique_ptr<LineNode> mXAxis;
|
||||
std::unique_ptr<LineNode> mYAxis;
|
||||
std::unique_ptr<LineNode> mZAxis;
|
||||
std::unique_ptr<LineNode> mStateVector;
|
||||
Ptr<CircleNode> mOuterCircle;
|
||||
Ptr<CircleNode> mInnerCircle;
|
||||
Ptr<CircleNode> mCentreCircle;
|
||||
Ptr<CircleNode> mStateMarkerCircle;
|
||||
Ptr<LineNode> mXAxis;
|
||||
Ptr<LineNode> mYAxis;
|
||||
Ptr<LineNode> mZAxis;
|
||||
Ptr<LineNode> mStateVector;
|
||||
};
|
||||
|
|
|
@ -29,10 +29,10 @@ private:
|
|||
bool mContentDirty{ true };
|
||||
QuantumCircuit* mContent{ nullptr };
|
||||
|
||||
std::vector<std::unique_ptr<QuantumTerminalNode> > mInputTerminalNodes;
|
||||
std::vector<std::unique_ptr<QuantumTerminalNode> > mOutputTerminalNodes;
|
||||
std::vector<std::unique_ptr<QuantumGateNode> > mGateNodes;
|
||||
std::vector<std::unique_ptr<QuantumWireNode> > mWireNodes;
|
||||
Vector<Ptr<QuantumTerminalNode> > mInputTerminalNodes;
|
||||
Vector<Ptr<QuantumTerminalNode> > mOutputTerminalNodes;
|
||||
Vector<Ptr<QuantumGateNode> > mGateNodes;
|
||||
Vector<Ptr<QuantumWireNode> > mWireNodes;
|
||||
|
||||
std::unordered_map<AbstractQuantumWire*, QuantumCircuitElement*> mWireInputConnections;
|
||||
std::unordered_map<AbstractQuantumWire*, QuantumCircuitElement*> mWireOutputConnections;
|
||||
|
|
|
@ -44,7 +44,7 @@ void QuantumGateNode::createOrUpdateGeometry(SceneInfo*)
|
|||
{
|
||||
mLabel = std::make_unique<EquationNode>(Point(mBodyWidth /3.0, mBodyHeight / 3.0));
|
||||
|
||||
std::string label_content;
|
||||
String label_content;
|
||||
if (mContent->getGateType() == QuantumGate::GateType::X)
|
||||
{
|
||||
label_content = "X";
|
||||
|
|
|
@ -25,10 +25,10 @@ private:
|
|||
QuantumGate* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::unique_ptr<RectangleNode> mBody;
|
||||
Ptr<RectangleNode> mBody;
|
||||
|
||||
double mBodyWidth = 30;
|
||||
double mBodyHeight = 24;
|
||||
std::unique_ptr<LatexMathExpression> mLabelExpression;
|
||||
std::unique_ptr<EquationNode> mLabel;
|
||||
Ptr<LatexMathExpression> mLabelExpression;
|
||||
Ptr<EquationNode> mLabel;
|
||||
};
|
|
@ -30,7 +30,7 @@ void QuantumTerminalNode::createOrUpdateGeometry(SceneInfo*)
|
|||
if (!mLabel && mContent->getTerminalType() != QuantumTerminal::TerminalType::OUTPUT)
|
||||
{
|
||||
const auto value = mContent->getValue();
|
||||
std::string label;
|
||||
String label;
|
||||
if (value.isIn0State())
|
||||
{
|
||||
label = "\\ket{0}";
|
||||
|
|
|
@ -25,6 +25,6 @@ private:
|
|||
double mWidth = 20.0;
|
||||
double mHeight = 10.0;
|
||||
|
||||
std::unique_ptr<LatexMathExpression> mLabelExpression;
|
||||
std::unique_ptr<EquationNode> mLabel;
|
||||
Ptr<LatexMathExpression> mLabelExpression;
|
||||
Ptr<EquationNode> mLabel;
|
||||
};
|
|
@ -54,7 +54,7 @@ void QuantumWireNode::createOrUpdateGeometry(SceneInfo*)
|
|||
auto loc = mOutputLocation;
|
||||
loc.moveBy(-mInputLocation.getX(), -mInputLocation.getY(), -mInputLocation.getZ());
|
||||
|
||||
std::vector<Point2> points;
|
||||
Vector<Point2> points;
|
||||
|
||||
if (loc.getY() == 0.0)
|
||||
{
|
||||
|
|
|
@ -29,5 +29,5 @@ private:
|
|||
Point2 mInputLocation;
|
||||
Point2 mOutputLocation;
|
||||
|
||||
std::unique_ptr<LineNode> mLine;
|
||||
Ptr<LineNode> mLine;
|
||||
};
|
|
@ -12,14 +12,25 @@ Status BuildLibrary::scan()
|
|||
{
|
||||
LOG_INFO("Scanning build file at: " << m_build_config);
|
||||
const auto search_dir = m_build_config.parent_path();
|
||||
const auto status = Directory::getFilesWithExtension(search_dir,
|
||||
|
||||
STATUS_CHECK(Directory::getFilesWithExtension(search_dir,
|
||||
".cpp",
|
||||
m_sources,
|
||||
true);
|
||||
return status;
|
||||
true), "Error collecting source files")
|
||||
|
||||
m_include_dirs.push_back(search_dir);
|
||||
|
||||
STATUS_CHECK(Directory::getAllSubDirectories(search_dir,
|
||||
m_include_dirs), "Error collecting include dirs")
|
||||
return {};
|
||||
}
|
||||
|
||||
const Vector<FileSystemPath>& BuildLibrary::get_sources() const
|
||||
{
|
||||
return m_sources;
|
||||
}
|
||||
|
||||
const Vector<FileSystemPath>& BuildLibrary::get_include_dirs() const
|
||||
{
|
||||
return m_include_dirs;
|
||||
}
|
|
@ -14,9 +14,11 @@ public:
|
|||
|
||||
const Vector<FileSystemPath>& get_sources() const;
|
||||
|
||||
const Vector<FileSystemPath>& get_include_dirs() const;
|
||||
|
||||
private:
|
||||
FileSystemPath m_build_config;
|
||||
Vector<FileSystemPath> m_sources;
|
||||
Vector<FileSystemPath> m_includes;
|
||||
Vector<FileSystemPath> m_include_dirs;
|
||||
String m_name;
|
||||
};
|
|
@ -16,6 +16,9 @@ BuildSession::BuildSession(const String& source_dir,
|
|||
{
|
||||
m_build_dir = build_dir;
|
||||
}
|
||||
m_compiler_flags.push_back("-g");
|
||||
m_compiler_flags.push_back("-fno-exceptions");
|
||||
m_compiler_flags.push_back("-fno-rtti");
|
||||
}
|
||||
|
||||
Status BuildSession::scan()
|
||||
|
@ -55,19 +58,22 @@ Status BuildSession::build()
|
|||
{
|
||||
for(const auto& source : library.get_sources())
|
||||
{
|
||||
String compiler_command = m_compiler_command + " -c ";
|
||||
compiler_command += source.str() + " ";
|
||||
LOG_INFO("Running command: " << compiler_command);
|
||||
|
||||
const auto self_name = Process::get_self_name();
|
||||
if (!self_name.ok())
|
||||
Vector<String> args = m_compiler_flags;
|
||||
args.push_back("-c");
|
||||
for(const auto& include_dir : library.get_include_dirs())
|
||||
{
|
||||
return Status(self_name.error());
|
||||
args.push_back(_s("-I") + include_dir.str());
|
||||
}
|
||||
LOG_INFO("Self name is: " << self_name.value());
|
||||
break;
|
||||
args.push_back(source.str());
|
||||
LOG_INFO("Compiling " << source.file_name());
|
||||
const auto run_status = Process::launch(m_compiler_command, args);
|
||||
if (!run_status.ok())
|
||||
{
|
||||
return run_status;
|
||||
}
|
||||
//break;
|
||||
}
|
||||
break;
|
||||
//break;
|
||||
}
|
||||
return {};
|
||||
}
|
|
@ -16,8 +16,8 @@ public:
|
|||
Status add_library(const FileSystemPath& config_path);
|
||||
|
||||
private:
|
||||
String m_compiler_command{"g++"};
|
||||
String m_compiler_flags{"-g -fno-exceptions -fno-rtti"};
|
||||
String m_compiler_command{"/usr/bin/g++"};
|
||||
Vector<String> m_compiler_flags;
|
||||
FileSystemPath m_source_dir;
|
||||
FileSystemPath m_build_dir;
|
||||
Vector<BuildLibrary> m_libraries;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Lexer.h"
|
||||
|
||||
bool Lexer::matchPattern(const std::string& pattern, const std::string& checkString, char delimiter, std::vector<std::string>& hitSequence)
|
||||
bool Lexer::matchPattern(const String& pattern, const String& checkString, char delimiter, Vector<String>& hitSequence)
|
||||
{
|
||||
if (checkString.empty())
|
||||
{
|
||||
|
@ -16,8 +16,8 @@ bool Lexer::matchPattern(const std::string& pattern, const std::string& checkStr
|
|||
unsigned check_idx = 0;
|
||||
unsigned pattern_idx = 0;
|
||||
|
||||
std::vector<std::string> hits;
|
||||
std::string working_hit;
|
||||
Vector<String> hits;
|
||||
String working_hit;
|
||||
while(check_idx < checkString.size())
|
||||
{
|
||||
if (pattern_idx == pattern.size())
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "String.h"
|
||||
#include "Vector.h"
|
||||
|
||||
class Lexer
|
||||
{
|
||||
public:
|
||||
// e.g. Pattern [@](@) returns <source, tag> for input: [source](tag) and delimiter @
|
||||
static bool matchPattern(const std::string& pattern, const std::string& checkString, char delimiter, std::vector<std::string>& hitSequence);
|
||||
static bool matchPattern(const String& pattern, const String& checkString, char delimiter, Vector<String>& hitSequence);
|
||||
};
|
||||
|
|
|
@ -5,50 +5,50 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
TemplateExtends::TemplateExtends(TemplateNode* parent, const std::string& path)
|
||||
TemplateExtends::TemplateExtends(TemplateNode* parent, const String& path)
|
||||
: TemplateNode(parent)
|
||||
{
|
||||
mPath = StringUtils::stripQuotes(path);
|
||||
};
|
||||
|
||||
std::string TemplateExtends::getRawContent() const
|
||||
String TemplateExtends::getRawContent() const
|
||||
{
|
||||
return "TemplateExtends: " + mPath;
|
||||
}
|
||||
|
||||
std::string TemplateExtends::getPath() const
|
||||
String TemplateExtends::getPath() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
TemplateBlock::TemplateBlock(TemplateNode* parent, const std::string& name)
|
||||
TemplateBlock::TemplateBlock(TemplateNode* parent, const String& name)
|
||||
: TemplateNode(parent),
|
||||
mName(name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TemplateBlock::addLine(const std::string& line)
|
||||
void TemplateBlock::addLine(const String& line)
|
||||
{
|
||||
mBody.push_back(line);
|
||||
}
|
||||
|
||||
std::string TemplateBlock::getRawContent() const
|
||||
String TemplateBlock::getRawContent() const
|
||||
{
|
||||
std::string content = "TemplateBlock: " + mName + " - Start \n";
|
||||
String content = "TemplateBlock: " + mName + " - Start \n";
|
||||
content += TemplateNode::getRawContent();
|
||||
content += "TemplateBlock: " + mName + " - End";
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string TemplateBlock::getIdentifier() const
|
||||
String TemplateBlock::getIdentifier() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
std::string TemplateBlock::renderAsParent(TemplateSubstitutionContext* substitutions, TemplateBlock* base)
|
||||
String TemplateBlock::renderAsParent(TemplateSubstitutionContext* substitutions, TemplateBlock* base)
|
||||
{
|
||||
std::string content;
|
||||
String content;
|
||||
for (auto& child : mChildren)
|
||||
{
|
||||
if (child->getType() == Type::EXPRESSION)
|
||||
|
@ -67,9 +67,9 @@ std::string TemplateBlock::renderAsParent(TemplateSubstitutionContext* substitut
|
|||
return content;
|
||||
}
|
||||
|
||||
std::string TemplateBlock::renderAsLeaf(TemplateSubstitutionContext* substitutions)
|
||||
String TemplateBlock::renderAsLeaf(TemplateSubstitutionContext* substitutions)
|
||||
{
|
||||
std::string content;
|
||||
String content;
|
||||
for (auto& child : mChildren)
|
||||
{
|
||||
if(child->getType() == Type::TEXT_BODY)
|
||||
|
@ -80,9 +80,9 @@ std::string TemplateBlock::renderAsLeaf(TemplateSubstitutionContext* substitutio
|
|||
return content;
|
||||
}
|
||||
|
||||
std::string TemplateBlock::render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext)
|
||||
String TemplateBlock::render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext)
|
||||
{
|
||||
std::string content;
|
||||
String content;
|
||||
if (parentContext)
|
||||
{
|
||||
if (auto parent_node = parentContext->getFirstChildShallow(Type::BLOCK, getIdentifier()))
|
||||
|
@ -101,19 +101,19 @@ std::string TemplateBlock::render(TemplateSubstitutionContext* substitutions, Te
|
|||
return content;
|
||||
}
|
||||
|
||||
TemplateExpression::TemplateExpression(TemplateNode* parent, const std::string& content)
|
||||
TemplateExpression::TemplateExpression(TemplateNode* parent, const String& content)
|
||||
: TemplateNode(parent),
|
||||
mContent(content)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const std::string& TemplateExpression::getContent() const
|
||||
const String& TemplateExpression::getContent() const
|
||||
{
|
||||
return mContent;
|
||||
}
|
||||
|
||||
std::string TemplateExpression::render(TemplateSubstitutionContext* substitutions, TemplateNode*)
|
||||
String TemplateExpression::render(TemplateSubstitutionContext* substitutions, TemplateNode*)
|
||||
{
|
||||
if (substitutions && substitutions->hasSubstitution(mContent))
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ std::string TemplateExpression::render(TemplateSubstitutionContext* substitution
|
|||
return {};
|
||||
}
|
||||
|
||||
std::string TemplateExpression::getRawContent() const
|
||||
String TemplateExpression::getRawContent() const
|
||||
{
|
||||
return "TemplateExpression: " + mContent;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ TemplateTextBody::TemplateTextBody(TemplateNode* parent)
|
|||
|
||||
}
|
||||
|
||||
void TemplateTextBody::addLine(const std::string& content)
|
||||
void TemplateTextBody::addLine(const String& content)
|
||||
{
|
||||
mContent.push_back(content);
|
||||
}
|
||||
|
@ -143,9 +143,9 @@ bool TemplateTextBody::hasContent() const
|
|||
return !mContent.empty();
|
||||
}
|
||||
|
||||
std::string TemplateTextBody::render(TemplateSubstitutionContext*, TemplateNode*)
|
||||
String TemplateTextBody::render(TemplateSubstitutionContext*, TemplateNode*)
|
||||
{
|
||||
std::string content;
|
||||
String content;
|
||||
for(unsigned idx=0; idx<mContent.size(); idx++)
|
||||
{
|
||||
content += mContent[idx];
|
||||
|
@ -157,9 +157,9 @@ std::string TemplateTextBody::render(TemplateSubstitutionContext*, TemplateNode*
|
|||
return content;
|
||||
}
|
||||
|
||||
std::string TemplateTextBody::getRawContent() const
|
||||
String TemplateTextBody::getRawContent() const
|
||||
{
|
||||
std::string content;
|
||||
String content;
|
||||
for(unsigned idx=0; idx<mContent.size(); idx++)
|
||||
{
|
||||
content += "Template Body L-" + std::to_string(idx) + ": " + mContent[idx];
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
class TemplateExtends : public TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateExtends(TemplateNode* parent, const std::string& path);
|
||||
TemplateExtends(TemplateNode* parent, const String& path);
|
||||
|
||||
virtual ~TemplateExtends() = default;
|
||||
|
||||
std::string getRawContent() const override;
|
||||
std::string getPath() const;
|
||||
String getRawContent() const override;
|
||||
String getPath() const;
|
||||
|
||||
Type getType() const override
|
||||
{
|
||||
|
@ -18,58 +18,58 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
std::string mPath;
|
||||
String mPath;
|
||||
};
|
||||
|
||||
class TemplateBlock : public TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateBlock(TemplateNode* parent, const std::string& name);
|
||||
TemplateBlock(TemplateNode* parent, const String& name);
|
||||
|
||||
virtual ~TemplateBlock() = default;
|
||||
|
||||
void addLine(const std::string& line);
|
||||
void addLine(const String& line);
|
||||
|
||||
std::string getRawContent() const override;
|
||||
String getRawContent() const override;
|
||||
|
||||
std::string getIdentifier() const override;
|
||||
String getIdentifier() const override;
|
||||
|
||||
Type getType() const override
|
||||
{
|
||||
return Type::BLOCK;
|
||||
}
|
||||
|
||||
std::string renderAsParent(TemplateSubstitutionContext* substitutions, TemplateBlock* base);
|
||||
String renderAsParent(TemplateSubstitutionContext* substitutions, TemplateBlock* base);
|
||||
|
||||
std::string renderAsLeaf(TemplateSubstitutionContext* substitutions);
|
||||
String renderAsLeaf(TemplateSubstitutionContext* substitutions);
|
||||
|
||||
std::string render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext) override;
|
||||
String render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext) override;
|
||||
|
||||
private:
|
||||
std::string mName;
|
||||
std::vector<std::string> mBody;
|
||||
String mName;
|
||||
Vector<String> mBody;
|
||||
};
|
||||
|
||||
class TemplateExpression : public TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateExpression(TemplateNode* parent, const std::string& content);
|
||||
TemplateExpression(TemplateNode* parent, const String& content);
|
||||
|
||||
virtual ~TemplateExpression() = default;
|
||||
|
||||
std::string getRawContent() const override;
|
||||
String getRawContent() const override;
|
||||
|
||||
const std::string& getContent() const;
|
||||
const String& getContent() const;
|
||||
|
||||
Type getType() const override
|
||||
{
|
||||
return Type::EXPRESSION;
|
||||
}
|
||||
|
||||
std::string render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext) override;
|
||||
String render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext) override;
|
||||
|
||||
private:
|
||||
std::string mContent;
|
||||
String mContent;
|
||||
};
|
||||
|
||||
class TemplateTextBody : public TemplateNode
|
||||
|
@ -79,18 +79,18 @@ public:
|
|||
|
||||
virtual ~TemplateTextBody() = default;
|
||||
|
||||
void addLine(const std::string& content);
|
||||
void addLine(const String& content);
|
||||
|
||||
std::string getRawContent() const override;
|
||||
String getRawContent() const override;
|
||||
|
||||
bool hasContent() const;
|
||||
|
||||
std::string render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext) override;
|
||||
String render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext) override;
|
||||
|
||||
Type getType() const override
|
||||
{
|
||||
return Type::TEXT_BODY;
|
||||
}
|
||||
private:
|
||||
std::vector<std::string> mContent;
|
||||
Vector<String> mContent;
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ TemplateFile::~TemplateFile()
|
|||
|
||||
}
|
||||
|
||||
std::string TemplateFile::getName() const
|
||||
String TemplateFile::getName() const
|
||||
{
|
||||
return mPath.stem().string();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ void TemplateFile::loadContent()
|
|||
mHasLoaded = true;
|
||||
}
|
||||
|
||||
std::string TemplateFile::dumpContent()
|
||||
String TemplateFile::dumpContent()
|
||||
{
|
||||
return mRootNode->getRawContent();
|
||||
}
|
||||
|
@ -73,14 +73,14 @@ void TemplateFile::onTextSpanFinished()
|
|||
mWorkingLineContent.clear();
|
||||
}
|
||||
|
||||
std::size_t TemplateFile::checkForStatement(const std::string& lineSection)
|
||||
std::size_t TemplateFile::checkForStatement(const String& lineSection)
|
||||
{
|
||||
if (lineSection.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> hits;
|
||||
Vector<String> hits;
|
||||
std::size_t hit_size{0};
|
||||
if (Lexer::matchPattern("{%@%}", lineSection, '@', hits))
|
||||
{
|
||||
|
@ -97,14 +97,14 @@ std::size_t TemplateFile::checkForStatement(const std::string& lineSection)
|
|||
return hit_size;
|
||||
}
|
||||
|
||||
std::size_t TemplateFile::checkForExpression(const std::string& lineSection)
|
||||
std::size_t TemplateFile::checkForExpression(const String& lineSection)
|
||||
{
|
||||
if (lineSection.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> hits;
|
||||
Vector<String> hits;
|
||||
std::size_t hit_size{0};
|
||||
if (Lexer::matchPattern("{{@}}", lineSection, '@', hits))
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ std::size_t TemplateFile::checkForExpression(const std::string& lineSection)
|
|||
return hit_size;
|
||||
}
|
||||
|
||||
void TemplateFile::processLine(const std::string& line)
|
||||
void TemplateFile::processLine(const String& line)
|
||||
{
|
||||
std::size_t line_position = 0;
|
||||
mWorkingLineContent.clear();
|
||||
|
@ -150,7 +150,7 @@ void TemplateFile::processLine(const std::string& line)
|
|||
}
|
||||
}
|
||||
|
||||
void TemplateFile::onFoundStatement(const std::string& statement_string)
|
||||
void TemplateFile::onFoundStatement(const String& statement_string)
|
||||
{
|
||||
const auto statement_elements = StringUtils::split(statement_string);
|
||||
if (statement_elements.size() == 0)
|
||||
|
@ -172,14 +172,14 @@ void TemplateFile::onFoundStatement(const std::string& statement_string)
|
|||
}
|
||||
}
|
||||
|
||||
void TemplateFile::onFoundExpression(const std::string& expression_string)
|
||||
void TemplateFile::onFoundExpression(const String& expression_string)
|
||||
{
|
||||
const auto stripped = StringUtils::stripSurroundingWhitepsace(expression_string);
|
||||
auto expression = std::make_unique<TemplateExpression>(mWorkingNode, stripped);
|
||||
mWorkingNode->addChild(std::move(expression));
|
||||
}
|
||||
|
||||
void TemplateFile::onFoundBlock(const std::vector<std::string> args)
|
||||
void TemplateFile::onFoundBlock(const Vector<String> args)
|
||||
{
|
||||
if (args.size() != 2)
|
||||
{
|
||||
|
@ -191,12 +191,12 @@ void TemplateFile::onFoundBlock(const std::vector<std::string> args)
|
|||
mWorkingNode = temp;
|
||||
}
|
||||
|
||||
void TemplateFile::onFoundEndBlock(const std::vector<std::string>)
|
||||
void TemplateFile::onFoundEndBlock(const Vector<String>)
|
||||
{
|
||||
mWorkingNode = mWorkingNode->getParent();
|
||||
}
|
||||
|
||||
void TemplateFile::onFoundExtends(const std::vector<std::string> args)
|
||||
void TemplateFile::onFoundExtends(const Vector<String> args)
|
||||
{
|
||||
if (args.size() != 2)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Vector.h"
|
||||
#include "String.h"
|
||||
#include <filesystem>
|
||||
|
||||
class TemplateNode;
|
||||
|
@ -16,9 +16,9 @@ public:
|
|||
|
||||
~TemplateFile();
|
||||
|
||||
std::string dumpContent();
|
||||
String dumpContent();
|
||||
|
||||
std::string getName() const;
|
||||
String getName() const;
|
||||
|
||||
TemplateNode* getContent() const;
|
||||
|
||||
|
@ -27,32 +27,32 @@ public:
|
|||
void loadContent();
|
||||
|
||||
private:
|
||||
std::size_t checkForStatement(const std::string& lineSection);
|
||||
std::size_t checkForStatement(const String& lineSection);
|
||||
|
||||
std::size_t checkForExpression(const std::string& lineSection);
|
||||
std::size_t checkForExpression(const String& lineSection);
|
||||
|
||||
void onTextSpanFinished();
|
||||
|
||||
void onFoundStatement(const std::string& statement_string);
|
||||
void onFoundStatement(const String& statement_string);
|
||||
|
||||
void onFoundExpression(const std::string& expression_string);
|
||||
void onFoundExpression(const String& expression_string);
|
||||
|
||||
void onFoundBlock(const std::vector<std::string> args);
|
||||
void onFoundBlock(const Vector<String> args);
|
||||
|
||||
void onFoundEndBlock(const std::vector<std::string> args);
|
||||
void onFoundEndBlock(const Vector<String> args);
|
||||
|
||||
void onFoundExtends(const std::vector<std::string> args);
|
||||
void onFoundExtends(const Vector<String> args);
|
||||
|
||||
void processLine(const std::string& line);
|
||||
void processLine(const String& line);
|
||||
|
||||
Path mPath;
|
||||
std::string mParentName;
|
||||
std::vector<std::string> mRawContent;
|
||||
String mParentName;
|
||||
Vector<String> mRawContent;
|
||||
bool mHasLoaded{false};
|
||||
|
||||
std::unique_ptr<TemplateNode> mRootNode;
|
||||
Ptr<TemplateNode> mRootNode;
|
||||
TemplateNode* mWorkingNode{ nullptr };
|
||||
|
||||
std::string mWorkingLineContent;
|
||||
std::unique_ptr<TemplateTextBody> mWorkingTextSpan;
|
||||
String mWorkingLineContent;
|
||||
Ptr<TemplateTextBody> mWorkingTextSpan;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ TemplateNode* TemplateNode::getParent() const
|
|||
return mParent;
|
||||
}
|
||||
|
||||
void TemplateNode::addChild(std::unique_ptr<TemplateNode> child)
|
||||
void TemplateNode::addChild(Ptr<TemplateNode> child)
|
||||
{
|
||||
mChildren.push_back(std::move(child));
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ std::size_t TemplateNode::getNumChildren() const
|
|||
return mChildren.size();
|
||||
}
|
||||
|
||||
TemplateNode* TemplateNode::getFirstChildShallow(Type type, const std::string& identifier) const
|
||||
TemplateNode* TemplateNode::getFirstChildShallow(Type type, const String& identifier) const
|
||||
{
|
||||
for (const auto& child : mChildren)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ TemplateNode::Type TemplateNode::getType() const
|
|||
return Type::NONE;
|
||||
}
|
||||
|
||||
std::string TemplateNode::getIdentifier() const
|
||||
String TemplateNode::getIdentifier() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ TemplateNode* TemplateNode::getChild(std::size_t index) const
|
|||
return mChildren[index].get();
|
||||
}
|
||||
|
||||
std::string TemplateNode::getRawContent() const
|
||||
String TemplateNode::getRawContent() const
|
||||
{
|
||||
std::string content;
|
||||
String content;
|
||||
for (const auto& child : mChildren)
|
||||
{
|
||||
content += child->getRawContent() + "\n";
|
||||
|
@ -80,7 +80,7 @@ void TemplateNode::setExtensionBase(TemplateNode* base)
|
|||
mExtensionBase = base;
|
||||
}
|
||||
|
||||
std::string TemplateNode::render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext)
|
||||
String TemplateNode::render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext)
|
||||
{
|
||||
if (mExtensionBase)
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ std::string TemplateNode::render(TemplateSubstitutionContext* substitutions, Tem
|
|||
parentContext = mExtensionParent;
|
||||
}
|
||||
|
||||
std::string content;
|
||||
String content;
|
||||
for (size_t idx = 0; idx < mChildren.size(); idx++)
|
||||
{
|
||||
content += mChildren[idx]->render(substitutions, parentContext);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Memory.h"
|
||||
#include "String.h"
|
||||
#include "Vector.h"
|
||||
|
||||
class TemplateSubstitutionContext;
|
||||
|
||||
|
@ -22,33 +22,33 @@ public:
|
|||
|
||||
virtual ~TemplateNode() = default;
|
||||
|
||||
virtual void addChild(std::unique_ptr<TemplateNode> child);
|
||||
virtual void addChild(Ptr<TemplateNode> child);
|
||||
|
||||
TemplateNode* getChild(std::size_t index) const;
|
||||
|
||||
TemplateNode* getFirstChildShallow(Type type, const std::string& identifier = {}) const;
|
||||
TemplateNode* getFirstChildShallow(Type type, const String& identifier = {}) const;
|
||||
|
||||
virtual std::string getIdentifier() const;
|
||||
virtual String getIdentifier() const;
|
||||
|
||||
std::size_t getNumChildren() const;
|
||||
|
||||
TemplateNode* getParent() const;
|
||||
|
||||
virtual std::string getRawContent() const;
|
||||
virtual String getRawContent() const;
|
||||
|
||||
virtual Type getType() const;
|
||||
|
||||
virtual std::string render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext = nullptr);
|
||||
virtual String render(TemplateSubstitutionContext* substitutions, TemplateNode* parentContext = nullptr);
|
||||
|
||||
void setExtensionParent(TemplateNode* parent);
|
||||
|
||||
void setExtensionBase(TemplateNode* base);
|
||||
|
||||
protected:
|
||||
std::vector<std::unique_ptr<TemplateNode> > mChildren;
|
||||
Vector<Ptr<TemplateNode> > mChildren;
|
||||
TemplateNode* mParent{ nullptr };
|
||||
TemplateNode* mExtensionParent{ nullptr };
|
||||
TemplateNode* mExtensionBase{ nullptr };
|
||||
};
|
||||
|
||||
using TemplateNodePtr = std::unique_ptr<TemplateNode>;
|
||||
using TemplateNodePtr = Ptr<TemplateNode>;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
#include <unordered_map>
|
||||
|
||||
class TemplateSubstitutionContext
|
||||
{
|
||||
public:
|
||||
|
||||
void addSubstitution(const std::string& key, const std::string& value)
|
||||
void addSubstitution(const String& key, const String& value)
|
||||
{
|
||||
mSubstitutions[key] = value;
|
||||
}
|
||||
|
||||
bool hasSubstitution(const std::string& key) const
|
||||
bool hasSubstitution(const String& key) const
|
||||
{
|
||||
return mSubstitutions.find(key) != mSubstitutions.end();
|
||||
}
|
||||
|
||||
std::string getSubstitution(const std::string& key) const
|
||||
String getSubstitution(const String& key) const
|
||||
{
|
||||
auto iter = mSubstitutions.find(key);
|
||||
if(iter != mSubstitutions.end())
|
||||
|
@ -31,5 +31,5 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> mSubstitutions;
|
||||
std::unordered_map<String, String> mSubstitutions;
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ TemplatingEngine::TemplatingEngine(const Path& workingDirectory)
|
|||
|
||||
}
|
||||
|
||||
std::string TemplatingEngine::renderTemplate(const std::string& name, TemplateSubstitutionContext* substitutionContext)
|
||||
String TemplatingEngine::renderTemplate(const String& name, TemplateSubstitutionContext* substitutionContext)
|
||||
{
|
||||
if (mTemplateFiles.empty())
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ TemplateFile* TemplatingEngine::getTemplateFile(const Path& path)
|
|||
return getTemplateFile(path.stem().string());
|
||||
}
|
||||
|
||||
TemplateFile* TemplatingEngine::getTemplateFile(const std::string& name)
|
||||
TemplateFile* TemplatingEngine::getTemplateFile(const String& name)
|
||||
{
|
||||
return mTemplateFiles[name].get();
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "File.h"
|
||||
#include "TemplateFile.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "Vector.h"
|
||||
#include "String.h"
|
||||
#include "Memory.h"
|
||||
#include <unordered_map>
|
||||
|
||||
class TemplateSubstitutionContext;
|
||||
|
@ -15,16 +15,16 @@ class TemplatingEngine
|
|||
public:
|
||||
TemplatingEngine(const Path& workingDirectory);
|
||||
|
||||
std::string renderTemplate(const std::string& name, TemplateSubstitutionContext* substitutionContext);
|
||||
String renderTemplate(const String& name, TemplateSubstitutionContext* substitutionContext);
|
||||
|
||||
private:
|
||||
TemplateFile* getTemplateFile(const std::string& name);
|
||||
TemplateFile* getTemplateFile(const String& name);
|
||||
TemplateFile* getTemplateFile(const Path& path);
|
||||
|
||||
void loadTemplateFiles();
|
||||
void processTemplate(TemplateFile* file, TemplateNode* parent = nullptr);
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<TemplateFile> > mTemplateFiles;
|
||||
std::unordered_map<String, Ptr<TemplateFile> > mTemplateFiles;
|
||||
Path mWorkingDirectory;
|
||||
std::string mTemplateExtension{ ".html" };
|
||||
String mTemplateExtension{ ".html" };
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "AbstractChecksumCalculator.h"
|
||||
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
class BitStream;
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
std::vector<AbstractChecksumCalculator*> mChecksumCalculators;
|
||||
Vector<AbstractChecksumCalculator*> mChecksumCalculators;
|
||||
BitStream* mInputStream{nullptr};
|
||||
BitStream* mOutputStream{nullptr};
|
||||
};
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue