Toward core module compiling.

This commit is contained in:
jmsgrogan 2023-12-27 12:20:02 +00:00
parent c25a56ee19
commit 3ed195d7dd
305 changed files with 1774 additions and 1065 deletions

View file

@ -1,8 +1,6 @@
#include "TomlReader.h"
#include <iostream>
#include <locale>
#include <algorithm>
#include "CharUtils.h"
TomlTable::TomlTable(const String& header)
: mHeader(header)
@ -12,17 +10,17 @@ TomlTable::TomlTable(const String& header)
void TomlTable::addComment(const Comment& comment)
{
mComments.push_back(comment);
//mComments.push_back(comment);
}
void TomlTable::addTable(Ptr<TomlTable> table)
{
mTables[table->getHeader()] = std::move(table);
mTables.insert(table->getHeader(), std::move(table));
}
void TomlTable::addKeyValuePair(const String& key, const String& value)
{
mMap[key] = value;
mMap.insert(key, value);
}
String TomlTable::getHeader() const
@ -30,49 +28,53 @@ String TomlTable::getHeader() const
return mHeader;
}
TomlTable* TomlTable::getTable(const String& path)
const TomlTable* TomlTable::getTable(const String& path)
{
return mTables[path].get();
return (*mTables.find(path)).value().get();
}
TomlTable::KeyValuePairs TomlTable::getKeyValuePairs() const
const TomlTable::KeyValuePairs& TomlTable::getKeyValuePairs() const
{
return mMap;
}
TomlContent::TomlContent()
: mRootTable(std::make_unique<TomlTable>("root"))
: mRootTable(Ptr<TomlTable>::create("root"))
{
}
TomlTable* TomlContent::getRootTable() const
const TomlTable* TomlContent::getRootTable() const
{
return mRootTable.get();
//return mRootTable.get();
return nullptr;
}
TomlTable* TomlContent::getTable(const String& path) const
const TomlTable* TomlContent::getTable(const String& path) const
{
return mRootTable->getTable(path);
//return mRootTable->getTable(path);
return nullptr;
}
TomlReader::TomlReader()
: mContent(std::make_unique<TomlContent>())
: mContent(Ptr<TomlContent>::create())
{
}
TomlContent* TomlReader::getContent() const
const TomlContent* TomlReader::getContent() const
{
return mContent.get();
//return mContent.get();
return nullptr;
}
void TomlReader::read(const Path& input_path)
void TomlReader::read(const FileSystemPath& input_path)
{
const auto lines = File(input_path).readLines();
Vector<String> lines;
File(input_path).readLines(lines);
mLastSectionOffset = 0;
mWorkingTable = mContent->getRootTable();
//mWorkingTable = mContent->getRootTable();
for (const auto& line : lines)
{
@ -126,11 +128,11 @@ void TomlReader::processLine(const String& line)
}
else if (found_key)
{
key_string.erase(std::remove_if(key_string.begin(), key_string.end(), [](char c) {return std::isspace(c); }), key_string.end());
working_string.erase(std::remove_if(working_string.begin(), working_string.end(), [](char c) {return std::isspace(c); }), working_string.end());
key_string.eraseIf([](char c) {return CharUtils::is_space(c); });
working_string.eraseIf([](char c) {return CharUtils::is_space(c); });
if (working_string.size()>2 && working_string[0] == '"' && working_string[working_string.size() - 1] == '"')
{
working_string = working_string.substr(1, working_string.size() - 2);
working_string.slice(1, working_string.size() - 2, working_string);
}
onKeyValuePair(key_string, working_string);
@ -139,7 +141,7 @@ void TomlReader::processLine(const String& line)
void TomlReader::onHeader(const String& header)
{
auto new_table = std::make_unique<TomlTable>(header);
auto new_table = Ptr<TomlTable>::create(header);
auto table_temp = new_table.get();
mWorkingTable->addTable(std::move(new_table));
mWorkingTable = table_temp;