stuff-from-scratch/plugins/quantum_computing/src/QuantumCircuitReader.h
2023-12-27 12:20:02 +00:00

40 lines
No EOL
800 B
C++

#pragma once
#include <filesystem>
#include "String.h"
using Path = std::filesystem::path;
class QuantumCircuit;
class QuantumCircuitElement;
class QuantumCircuitReader
{
public:
Ptr<QuantumCircuit> read(const Path& path);
Ptr<QuantumCircuit> read(const String& content);
private:
using Location = std::pair<size_t, size_t>;
void onLine(const String& line, size_t jdx);
String checkForKet(const String& segment);
String checkForGate(const String& segment);
size_t getWireEnd(const String& segment);
void onGate(Location loc, const String value);
void onKet(Location loc, const String value);
void onLineEnd();
void onVertialQuantumWire(Location loc);
String mWorkingString;
QuantumCircuitElement* mWorkingElement{ nullptr };
QuantumCircuit* mWorkingCircuit{ nullptr };
};