mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
refactor: remove set_location
This commit is contained in:
@@ -54,7 +54,6 @@ class location
|
|||||||
{
|
{
|
||||||
return this->location_;
|
return this->location_;
|
||||||
}
|
}
|
||||||
void set_location(const std::size_t loc) noexcept;
|
|
||||||
|
|
||||||
std::size_t line_number() const noexcept
|
std::size_t line_number() const noexcept
|
||||||
{
|
{
|
||||||
|
@@ -66,30 +66,6 @@ TOML11_INLINE location::char_type location::peek()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TOML11_INLINE void location::set_location(const std::size_t loc) noexcept
|
|
||||||
{
|
|
||||||
if(this->location_ == loc)
|
|
||||||
{
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(loc == 0)
|
|
||||||
{
|
|
||||||
this->line_number_ = 1;
|
|
||||||
}
|
|
||||||
else if(this->location_ < loc)
|
|
||||||
{
|
|
||||||
const auto d = loc - this->location_;
|
|
||||||
this->advance_line_number(d);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto d = this->location_ - loc;
|
|
||||||
this->retrace_line_number(d);
|
|
||||||
}
|
|
||||||
this->location_ = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
TOML11_INLINE std::string location::get_line() const
|
TOML11_INLINE std::string location::get_line() const
|
||||||
{
|
{
|
||||||
assert(this->is_ok());
|
assert(this->is_ok());
|
||||||
|
@@ -3459,7 +3459,7 @@ parse_impl(std::vector<location::char_type> cs, std::string fname, const spec& s
|
|||||||
// skip BOM if found
|
// skip BOM if found
|
||||||
if(loc.source()->size() >= 3)
|
if(loc.source()->size() >= 3)
|
||||||
{
|
{
|
||||||
auto first = loc.get_location();
|
auto first = loc;
|
||||||
|
|
||||||
const auto c0 = loc.current(); loc.advance();
|
const auto c0 = loc.current(); loc.advance();
|
||||||
const auto c1 = loc.current(); loc.advance();
|
const auto c1 = loc.current(); loc.advance();
|
||||||
@@ -3468,7 +3468,7 @@ parse_impl(std::vector<location::char_type> cs, std::string fname, const spec& s
|
|||||||
const auto bom_found = (c0 == 0xEF) && (c1 == 0xBB) && (c2 == 0xBF);
|
const auto bom_found = (c0 == 0xEF) && (c1 == 0xBB) && (c2 == 0xBF);
|
||||||
if( ! bom_found)
|
if( ! bom_found)
|
||||||
{
|
{
|
||||||
loc.set_location(first);
|
loc = first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user