mirror of
https://github.com/mariiaan/minipp.git
synced 2026-05-14 10:11:17 +02:00
Add fstream compability
This commit is contained in:
@@ -294,7 +294,9 @@ namespace minipp
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
EResult Parse(const std::string& path, bool additional = false) noexcept;
|
EResult Parse(const std::string& path, bool additional = false) noexcept;
|
||||||
|
EResult Parse(std::ifstream& ifs, bool additional = false) noexcept;
|
||||||
EResult Write(const std::string& path) const noexcept;
|
EResult Write(const std::string& path) const noexcept;
|
||||||
|
EResult Write(std::ofstream& ofs) const noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Section& GetRoot() const noexcept { return m_rootSection; }
|
const Section& GetRoot() const noexcept { return m_rootSection; }
|
||||||
@@ -852,6 +854,13 @@ minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::of
|
|||||||
}
|
}
|
||||||
|
|
||||||
minipp::EResult minipp::MiniPPFile::Parse(const std::string& path, bool additional) noexcept
|
minipp::EResult minipp::MiniPPFile::Parse(const std::string& path, bool additional) noexcept
|
||||||
|
{
|
||||||
|
std::ifstream ifs;
|
||||||
|
ifs.open(path);
|
||||||
|
return Parse(ifs, additional);
|
||||||
|
}
|
||||||
|
|
||||||
|
minipp::EResult minipp::MiniPPFile::Parse(std::ifstream& ifs, bool additional) noexcept
|
||||||
{
|
{
|
||||||
#define PP_COUT_HERE() PP_COUT_SYNTAX_ERROR_LINE(lineCounter, currentLine << " <- HERE");
|
#define PP_COUT_HERE() PP_COUT_SYNTAX_ERROR_LINE(lineCounter, currentLine << " <- HERE");
|
||||||
if (!additional)
|
if (!additional)
|
||||||
@@ -861,8 +870,6 @@ minipp::EResult minipp::MiniPPFile::Parse(const std::string& path, bool addition
|
|||||||
m_rootSection.m_subSections.clear();
|
m_rootSection.m_subSections.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream ifs;
|
|
||||||
ifs.open(path);
|
|
||||||
if (!ifs.is_open())
|
if (!ifs.is_open())
|
||||||
return EResult::FileIOError;
|
return EResult::FileIOError;
|
||||||
|
|
||||||
@@ -996,6 +1003,12 @@ minipp::EResult minipp::MiniPPFile::Write(const std::string& path) const noexcep
|
|||||||
{
|
{
|
||||||
std::ofstream ofs;
|
std::ofstream ofs;
|
||||||
ofs.open(path);
|
ofs.open(path);
|
||||||
|
|
||||||
|
return Write(ofs);
|
||||||
|
}
|
||||||
|
|
||||||
|
minipp::EResult minipp::MiniPPFile::Write(std::ofstream& ofs) const noexcept
|
||||||
|
{
|
||||||
if (!ofs.is_open())
|
if (!ofs.is_open())
|
||||||
return EResult::FileIOError;
|
return EResult::FileIOError;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user