Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy nested namespaces #396

Merged
merged 4 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Split out more types
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
  • Loading branch information
mjcarroll committed Jan 4, 2024
commit 097ce9ea4b585c5fdc3cff8651f9902e12f116d2
57 changes: 57 additions & 0 deletions include/gz/fuel_tools/HttpMethod.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2017 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GZ_FUEL_TOOLS_HTTPMETHOD_HH_
#define GZ_FUEL_TOOLS_HTTPMETHOD_HH_

#include <map>
#include <memory>
#include <string>
#include <vector>

#if defined(_WIN32) && defined(DELETE)
#undef DELETE
#endif

namespace gz::fuel_tools
{
/// \brief the types of HTTP methods
enum class HttpMethod
{
/// \brief Get method.
GET,

/// \brief Post method.
POST,

/// \brief Delete method.
DELETE,

/// \brief Put method.
PUT,

/// \brief Patch method.
PATCH,

/// \brief Post form method.
POST_FORM,

/// \brief Patch form method.
PATCH_FORM
};
} // namespace gz::fuel_tools

#endif // GZ_FUEL_TOOLS_HTTPMETHOD_HH_
28 changes: 1 addition & 27 deletions include/gz/fuel_tools/RestClient.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
#include <vector>

#include "gz/fuel_tools/Export.hh"
#include "gz/fuel_tools/HttpMethod.hh"

#ifdef _WIN32
// Disable warning C4251 which is triggered by
// std::string
#pragma warning(push)
#pragma warning(disable: 4251)
// TODO(jrivero): rename the DELETE method which is a reserved word in Windows
#undef DELETE
#endif

namespace gz::fuel_tools
Expand All @@ -51,31 +50,6 @@ namespace gz::fuel_tools
public: std::map<std::string, std::string> headers;
};

/// \brief the types of HTTP methods
enum class HttpMethod
{
/// \brief Get method.
GET,

/// \brief Post method.
POST,

/// \brief Delete method.
DELETE,

/// \brief Put method.
PUT,

/// \brief Patch method.
PATCH,

/// \brief Post form method.
POST_FORM,

/// \brief Patch form method.
PATCH_FORM
};

/// \brief A helper class for making REST requests.
class GZ_FUEL_TOOLS_VISIBLE Rest
{
Expand Down
49 changes: 1 addition & 48 deletions include/gz/fuel_tools/Result.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
#include <string>

#include "gz/fuel_tools/Export.hh"
#include "gz/fuel_tools/ResultType.hh"

#ifdef _WIN32
// Disable warning C4251 which is triggered by
// std::unique_ptr
#pragma warning(push)
#pragma warning(disable: 4251)
// TODO(jrivero): rename the DELETE method which is a reserved word in Windows
#undef DELETE
#endif

namespace gz::fuel_tools
Expand All @@ -38,52 +37,6 @@ namespace gz::fuel_tools
class ResultPrivate;
class Model;

/// Result type.
enum class ResultType
{
/// \brief Uninitialized type.
UNKNOWN = 0,

/// \brief Delete successful.
DELETE,

/// \brief Model not found.
DELETE_NOT_FOUND,

/// \brief Delete failed. Other errors.
/// \sa ReadableResult
DELETE_ERROR,

/// \brief Fetch successful.
FETCH,

/// \brief Model already exists.
FETCH_ALREADY_EXISTS,

/// \brief Model not found.
FETCH_NOT_FOUND,

/// \brief Fetch failed. Other errors.
/// \sa ReadableResult
FETCH_ERROR,

/// \brief Upload successful.
UPLOAD,

/// \brief Model already exists.
UPLOAD_ALREADY_EXISTS,

/// \brief Upload failed. Other errors.
/// \sa ReadableResult
UPLOAD_ERROR,

/// \brief Patch failed.
PATCH_ERROR,

/// \brief Patch successful.
PATCH,
};

/// \brief Class describing a result of an operation.
class GZ_FUEL_TOOLS_VISIBLE Result
{
Expand Down
77 changes: 77 additions & 0 deletions include/gz/fuel_tools/ResultType.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2017 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef GZ_FUEL_TOOLS_RESULTTYPE_HH_
#define GZ_FUEL_TOOLS_RESULTTYPE_HH_

#include <memory>
#include <string>

#if defined(_WIN32) && defined(DELETE)
#undef DELETE
#endif

namespace gz::fuel_tools
{
/// Result type.
enum class ResultType
{
/// \brief Uninitialized type.
UNKNOWN = 0,

/// \brief Delete successful.
DELETE,

/// \brief Model not found.
DELETE_NOT_FOUND,

/// \brief Delete failed. Other errors.
/// \sa ReadableResult
DELETE_ERROR,

/// \brief Fetch successful.
FETCH,

/// \brief Model already exists.
FETCH_ALREADY_EXISTS,

/// \brief Model not found.
FETCH_NOT_FOUND,

/// \brief Fetch failed. Other errors.
/// \sa ReadableResult
FETCH_ERROR,

/// \brief Upload successful.
UPLOAD,

/// \brief Model already exists.
UPLOAD_ALREADY_EXISTS,

/// \brief Upload failed. Other errors.
/// \sa ReadableResult
UPLOAD_ERROR,

/// \brief Patch failed.
PATCH_ERROR,

/// \brief Patch successful.
PATCH,
};
} // namespace gz::fuel_tools

#endif // GZ_FUEL_TOOLS_RESULTTYPE_HH_
4 changes: 0 additions & 4 deletions src/RestClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
*/

#include <curl/curl.h>
#ifdef _WIN32
// DELETE is defined in winnt.h and causes a problem with HttpMethod::DELETE
#undef DELETE
#endif

#include <cstring>
#include <iostream>
Expand Down
5 changes: 0 additions & 5 deletions src/gz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
#include <gz/msgs/fuel_metadata.pb.h>
#include <gz/msgs/Utility.hh>

#ifdef _WIN32
// DELETE is defined in winnt.h and causes a problem with REST::DELETE
#undef DELETE
#endif

#include <algorithm>
#include <chrono>
#include <deque>
Expand Down