xlnt/include/xlnt/packaging/uri.hpp

226 lines
4.2 KiB
C++
Raw Normal View History

// Copyright (c) 2014-2016 Thomas Fussell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE
//
// @license: http://www.opensource.org/licenses/mit-license.php
// @author: see AUTHORS file
#pragma once
#include <string>
#include <xlnt/xlnt_config.hpp>
2016-08-10 18:32:09 +08:00
#include <xlnt/utils/path.hpp>
namespace xlnt {
/// <summary>
2016-08-10 18:32:09 +08:00
///
/// </summary>
class XLNT_API uri
{
public:
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
uri();
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
uri(const uri &base, const uri &relative);
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
uri(const uri &base, const path &relative);
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
uri(const std::string &uri_string);
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool is_relative() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool is_absolute() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string scheme() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string authority() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool has_authentication() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string authentication() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string username() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string password() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string host() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool has_port() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::size_t port() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2016-12-03 23:31:10 +08:00
class path path() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool has_query() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string query() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool has_fragment() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string fragment() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string to_string() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
uri make_absolute(const uri &base);
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
uri make_reference(const uri &base);
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
friend XLNT_API bool operator==(const uri &left, const uri &right);
private:
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool absolute_ = false;
/// <summary>
///
/// </summary>
std::string scheme_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool has_authentication_ = false;
/// <summary>
///
/// </summary>
std::string username_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string password_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
std::string host_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool has_port_ = false;
/// <summary>
///
/// </summary>
std::size_t port_ = 0;
/// <summary>
///
/// </summary>
bool has_query_ = false;
/// <summary>
///
/// </summary>
std::string query_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool has_fragment_ = false;
/// <summary>
///
/// </summary>
std::string fragment_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
class path path_;
};
} // namespace xlnt