Delete Parse:: and IParseError.#447
Merged
BillyONeal merged 2 commits intomicrosoft:mainfrom Mar 22, 2022
Merged
Conversation
Extracted from microsoft#345 to make that PR easier to review.
Contributor
|
I'd also like From ea51146c19e4ddf1f5086c2c3530bb002cd019ad Mon Sep 17 00:00:00 2001
From: nicole mazzuca <mazzucan@outlook.com>
Date: Tue, 22 Mar 2022 10:21:09 -0700
Subject: [PATCH] remove IParseError
---
include/vcpkg/base/fwd/parse.h | 1 -
include/vcpkg/base/json.h | 4 ++--
include/vcpkg/base/parse.h | 17 +++++------------
src/vcpkg/base/json.cpp | 8 ++++----
4 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/include/vcpkg/base/fwd/parse.h b/include/vcpkg/base/fwd/parse.h
index d6cce6f39..633ed0c13 100644
--- a/include/vcpkg/base/fwd/parse.h
+++ b/include/vcpkg/base/fwd/parse.h
@@ -2,7 +2,6 @@
namespace vcpkg
{
- struct IParseError;
struct ParseError;
struct SourceLoc;
diff --git a/include/vcpkg/base/json.h b/include/vcpkg/base/json.h
index ccb7d7eed..9c200aca7 100644
--- a/include/vcpkg/base/json.h
+++ b/include/vcpkg/base/json.h
@@ -289,10 +289,10 @@ namespace vcpkg::Json
underlying_t underlying_;
};
- ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<IParseError>> parse_file(const Filesystem&,
+ ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<ParseError>> parse_file(const Filesystem&,
const Path&,
std::error_code& ec) noexcept;
- ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<IParseError>> parse(StringView text,
+ ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<ParseError>> parse(StringView text,
StringView origin = {}) noexcept;
std::pair<Value, JsonStyle> parse_file(vcpkg::LineInfo li, const Filesystem&, const Path&) noexcept;
diff --git a/include/vcpkg/base/parse.h b/include/vcpkg/base/parse.h
index 45065fa21..053f8a6d7 100644
--- a/include/vcpkg/base/parse.h
+++ b/include/vcpkg/base/parse.h
@@ -15,14 +15,7 @@
namespace vcpkg
{
- struct IParseError
- {
- virtual ~IParseError() = default;
- virtual std::string format() const = 0;
- virtual const std::string& get_message() const = 0;
- };
-
- struct ParseError : IParseError
+ struct ParseError
{
ParseError(std::string origin, int row, int column, int caret_col, std::string line, std::string message)
: origin(std::move(origin))
@@ -41,8 +34,8 @@ namespace vcpkg
const std::string line;
const std::string message;
- virtual std::string format() const override;
- virtual const std::string& get_message() const override;
+ std::string format() const;
+ const std::string& get_message() const;
};
struct SourceLoc
@@ -143,8 +136,8 @@ namespace vcpkg
void add_warning(LocalizedString&& message) { add_warning(std::move(message), cur_loc()); }
void add_warning(LocalizedString&& message, const SourceLoc& loc);
- const IParseError* get_error() const { return m_messages.error.get(); }
- std::unique_ptr<IParseError> extract_error() { return std::move(m_messages.error); }
+ const ParseError* get_error() const { return m_messages.error.get(); }
+ std::unique_ptr<ParseError> extract_error() { return std::move(m_messages.error); }
const ParseMessages& messages() const { return m_messages; }
ParseMessages extract_messages() { return std::move(m_messages); }
diff --git a/src/vcpkg/base/json.cpp b/src/vcpkg/base/json.cpp
index 8c3a295b5..1be02d84f 100644
--- a/src/vcpkg/base/json.cpp
+++ b/src/vcpkg/base/json.cpp
@@ -981,7 +981,7 @@ namespace vcpkg::Json
}
}
- static ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<IParseError>> parse(
+ static ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<ParseError>> parse(
StringView json, StringView origin) noexcept
{
StatsTimer t(g_json_parsing_stats);
@@ -1072,14 +1072,14 @@ namespace vcpkg::Json
return true;
}
- ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<IParseError>> parse_file(const Filesystem& fs,
+ ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<ParseError>> parse_file(const Filesystem& fs,
const Path& json_file,
std::error_code& ec) noexcept
{
auto res = fs.read_contents(json_file, ec);
if (ec)
{
- return std::unique_ptr<IParseError>();
+ return std::unique_ptr<ParseError>();
}
return parse(std::move(res), json_file);
@@ -1103,7 +1103,7 @@ namespace vcpkg::Json
return ret.value_or_exit(li);
}
- ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<IParseError>> parse(StringView json,
+ ExpectedT<std::pair<Value, JsonStyle>, std::unique_ptr<ParseError>> parse(StringView json,
StringView origin) noexcept
{
return Parser::parse(json, origin);
--
2.32.0 (Apple Git-132) |
strega-nil-ms
approved these changes
Mar 22, 2022
Member
Author
|
/azp run |
Member
Author
|
I manually forced a build: https://dev.azure.com/vcpkg/public/_build/results?buildId=69235&view=results |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from #345 to make that PR easier to review.