Release v1.1.2

This commit is contained in:
2025-12-18 15:38:49 +05:30
parent 6e72d213e3
commit d1f6ff5a77
4 changed files with 104 additions and 10 deletions

View File

@ -27,10 +27,9 @@ namespace IACore
for (const auto &h : headers) for (const auto &h : headers)
{ {
std::string key = HttpClient::HeaderTypeToString(h.first); out.emplace(h.first, h.second);
out.emplace(key, h.second);
if (h.first == HttpClient::EHeaderType::CONTENT_TYPE) if (h.first == HttpClient::HeaderTypeToString(HttpClient::EHeaderType::CONTENT_TYPE))
hasContentType = true; hasContentType = true;
} }
@ -132,11 +131,6 @@ namespace IACore
namespace IACore namespace IACore
{ {
HttpClient::Header HttpClient::CreateHeader(IN EHeaderType key, IN CONST String &value)
{
return std::make_pair(key, value);
}
String HttpClient::UrlEncode(IN CONST String &value) String HttpClient::UrlEncode(IN CONST String &value)
{ {
std::stringstream escaped; std::stringstream escaped;

View File

@ -0,0 +1,51 @@
// IACore-OSS; The Core Library for All IA Open Source Projects
// Copyright (C) 2025 IAS (ias@iasoft.dev)
//
// 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.
#include <IACore/XML.hpp>
namespace IACore
{
Expected<XML::Document, String> XML::ParseFromString(IN CONST String &data)
{
Document doc;
const auto parseResult = doc.load_string(data.data());
if (!parseResult)
return MakeUnexpected(std::format("Failed to parse XML: {}", parseResult.description()));
return IA_MOVE(doc);
}
Expected<XML::Document, String> XML::ParseFromFile(IN CONST FilePath &path)
{
Document doc;
const auto parseResult = doc.load_file(path.string().c_str());
if (!parseResult)
return MakeUnexpected(std::format("Failed to parse XML: {}", parseResult.description()));
return IA_MOVE(doc);
}
String XML::SerializeToString(IN CONST Node &node)
{
std::ostringstream oss;
node.print(oss);
return oss.str();
}
String XML::SerializeToString(IN CONST Document &doc)
{
std::ostringstream oss;
doc.save(oss);
return oss.str();
}
} // namespace IACore

View File

@ -127,7 +127,7 @@ namespace IACore
NETWORK_AUTHENTICATION_REQUIRED = 511 NETWORK_AUTHENTICATION_REQUIRED = 511
}; };
using Header = KeyValuePair<EHeaderType, String>; using Header = KeyValuePair<String, String>;
public: public:
HttpClient(IN CONST String &host); HttpClient(IN CONST String &host);
@ -151,7 +151,9 @@ namespace IACore
STATIC String UrlDecode(IN CONST String &value); STATIC String UrlDecode(IN CONST String &value);
STATIC String HeaderTypeToString(IN EHeaderType type); STATIC String HeaderTypeToString(IN EHeaderType type);
STATIC Header CreateHeader(IN EHeaderType key, IN CONST String &value);
STATIC INLINE Header CreateHeader(IN EHeaderType key, IN CONST String &value);
STATIC INLINE Header CreateHeader(IN CONST String &key, IN CONST String &value);
STATIC BOOL IsSuccessResponseCode(IN EResponseCode code); STATIC BOOL IsSuccessResponseCode(IN EResponseCode code);
@ -192,4 +194,14 @@ namespace IACore
return MakeUnexpected(std::format("Server responded with code {}", (INT32) LastResponseCode())); return MakeUnexpected(std::format("Server responded with code {}", (INT32) LastResponseCode()));
return JSON::ParseToStruct<_response_type>(*rawResponse); return JSON::ParseToStruct<_response_type>(*rawResponse);
} }
HttpClient::Header HttpClient::CreateHeader(IN EHeaderType key, IN CONST String &value)
{
return std::make_pair(HeaderTypeToString(key), value);
}
HttpClient::Header HttpClient::CreateHeader(IN CONST String &key, IN CONST String &value)
{
return std::make_pair(key, value);
}
} // namespace IACore } // namespace IACore

View File

@ -0,0 +1,37 @@
// IACore-OSS; The Core Library for All IA Open Source Projects
// Copyright (C) 2025 IAS (ias@iasoft.dev)
//
// 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.
#pragma once
#include <IACore/PCH.hpp>
#include <pugixml.hpp>
namespace IACore
{
class XML
{
public:
using Node = pugi::xml_node;
using Document = pugi::xml_document;
public:
STATIC Expected<Document, String> ParseFromString(IN CONST String &data);
STATIC Expected<Document, String> ParseFromFile(IN CONST FilePath &path);
STATIC String SerializeToString(IN CONST Node &node);
STATIC String SerializeToString(IN CONST Document &doc);
};
} // namespace IACore