anthracite/lib/http/header_query.hpp
Nicholas Orlowsky 71be773d49
split into src and lib and socket changes
* libanthracite files are now all in lib/
* anthracite-bin + anthracite-api-bin files are now all in src/
* socket split into header and source properly
2025-02-04 11:37:46 -05:00

61 lines
1.2 KiB
C++

#pragma once
#include <string>
namespace anthracite::http {
class name_value {
private:
std::string _name;
std::string _value;
protected:
name_value() {}
public:
name_value(std::string name, std::string value)
: _name(std::move(name))
, _value(std::move(value))
{
}
virtual ~name_value() = default;
name_value(const name_value&) = default;
name_value& operator=(name_value const&) = default;
name_value(name_value&&) = default;
name_value& operator=(name_value&&) = default;
std::string& name() { return _name; }
std::string& value() { return _value; }
virtual std::string to_string() { return ""; }
};
class header : public name_value {
public:
header()
: name_value()
{
}
header(std::string name, std::string value)
: name_value(name, value)
{
}
std::string to_string() override { return name() + ": " + value() + "\r\n"; }
};
class query_param : public name_value {
public:
query_param()
: name_value()
{
}
query_param(std::string name, std::string value)
: name_value(name, value)
{
}
std::string to_string() override { return name() + "=" + value(); }
};
};