#pragma once

#include <filesystem>
#include <string>

using Path = std::filesystem::path;

class QuantumCircuit;
class QuantumCircuitElement;

class QuantumCircuitReader
{
public:
	std::unique_ptr<QuantumCircuit> read(const Path& path);

	std::unique_ptr<QuantumCircuit> read(const std::string& content);

private:
	using Location = std::pair<std::size_t, std::size_t>;

	void onLine(const std::string& line, std::size_t jdx);

	std::string checkForKet(const std::string& segment);

	std::string checkForGate(const std::string& segment);

	std::size_t getWireEnd(const std::string& segment);

	void onGate(Location loc, const std::string value);

	void onKet(Location loc, const std::string value);

	void onLineEnd();

	void onVertialQuantumWire(Location loc);

	std::string mWorkingString;
	QuantumCircuitElement* mWorkingElement{ nullptr };
	QuantumCircuit* mWorkingCircuit{ nullptr };
};