#ifndef TILE_BASE_ENCODING_PERCENT_H
#define TILE_BASE_ENCODING_PERCENT_H

#pragma once

#include "tile/base/internal/early_init.h"
#include "tile/base/optional.h"
#include "tile/base/slice.h"

namespace tile {
enum class PercentEncodingStyle {
    Ecma262 = 0,
    Rfc3986 = 1,
    Rfc5987 = 2,
};

struct PercentEncodingOptions {
    PercentEncodingStyle style = PercentEncodingStyle::Rfc3986;
    bool escape_reserved       = true;

    PercentEncodingOptions(PercentEncodingStyle s = PercentEncodingStyle::Rfc3986, bool escape_reserved = true);
};

std::string
EncodePercent(Slice from,
              const PercentEncodingOptions &options = internal::EarlyInitConstant<PercentEncodingOptions>());
std::optional<std::string> DecodePercent(Slice from, bool decode_plus_sign_as_whitespace = false);

void EncodePercent(Slice from,
                   std::string *to,
                   const PercentEncodingOptions &options = internal::EarlyInitConstant<PercentEncodingOptions>());
bool DecodePercent(Slice from, std::string *to, bool decode_plus_sign_as_whitespace = false);

}// namespace tile

#endif// TILE_BASE_ENCODING_PERCENT_H
