Skip to content

Delete Parse:: and IParseError.#447

Merged
BillyONeal merged 2 commits intomicrosoft:mainfrom
BillyONeal:remove-parse-namespace
Mar 22, 2022
Merged

Delete Parse:: and IParseError.#447
BillyONeal merged 2 commits intomicrosoft:mainfrom
BillyONeal:remove-parse-namespace

Conversation

@BillyONeal
Copy link
Member

Extracted from #345 to make that PR easier to review.

Extracted from microsoft#345 to make that PR easier to review.
@strega-nil-ms
Copy link
Contributor

I'd also like IParseError to be removed as part of this if possible:

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)

@BillyONeal BillyONeal changed the title Delete Parse::. Delete Parse:: and IParseError. Mar 22, 2022
@BillyONeal BillyONeal closed this Mar 22, 2022
@BillyONeal BillyONeal reopened this Mar 22, 2022
@BillyONeal
Copy link
Member Author

/azp run

@BillyONeal
Copy link
Member Author

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@BillyONeal BillyONeal merged commit 3425b09 into microsoft:main Mar 22, 2022
@BillyONeal BillyONeal deleted the remove-parse-namespace branch March 22, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants