2023-01-26 11:27:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <filesystem>
|
2023-12-21 09:18:44 +00:00
|
|
|
#include "String.h"
|
2023-01-26 11:27:35 +00:00
|
|
|
|
|
|
|
using Path = std::filesystem::path;
|
|
|
|
|
|
|
|
class QuantumCircuit;
|
|
|
|
class QuantumCircuitElement;
|
|
|
|
|
|
|
|
class QuantumCircuitReader
|
|
|
|
{
|
|
|
|
public:
|
2023-12-21 09:18:44 +00:00
|
|
|
Ptr<QuantumCircuit> read(const Path& path);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
Ptr<QuantumCircuit> read(const String& content);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
using Location = std::pair<std::size_t, std::size_t>;
|
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
void onLine(const String& line, std::size_t jdx);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
String checkForKet(const String& segment);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
String checkForGate(const String& segment);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
std::size_t getWireEnd(const String& segment);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
void onGate(Location loc, const String value);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
void onKet(Location loc, const String value);
|
2023-01-26 11:27:35 +00:00
|
|
|
|
|
|
|
void onLineEnd();
|
|
|
|
|
|
|
|
void onVertialQuantumWire(Location loc);
|
|
|
|
|
2023-12-21 09:18:44 +00:00
|
|
|
String mWorkingString;
|
2023-01-26 11:27:35 +00:00
|
|
|
QuantumCircuitElement* mWorkingElement{ nullptr };
|
|
|
|
QuantumCircuit* mWorkingCircuit{ nullptr };
|
|
|
|
};
|