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