Files
moloapp/src/anthropic/admin/query.h
T

36 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
// Query: the query-string parameters of one call, built by name. Array
// parameters are added repeatedly (`add`); the request builder checks names,
// counts and sizes against the call table and encodes `name[]=a&name[]=b`.
#include <string>
#include <utility>
#include <vector>
namespace molo::anthropic::admin {
class Query {
public:
Query() = default;
// Replaces any earlier value of `name`.
Query& set(const std::string& name, const std::string& value);
Query& set_int(const std::string& name, long value);
Query& set_bool(const std::string& name, bool value);
// Appends a value (array parameters: statuses, roles, group_by, ...).
Query& add(const std::string& name, const std::string& value);
bool empty() const { return items_.empty(); }
bool has(const std::string& name) const;
// First value of `name`, or "".
std::string get(const std::string& name) const;
std::size_t count(const std::string& name) const;
const std::vector<std::pair<std::string, std::string>>& items() const { return items_; }
private:
std::vector<std::pair<std::string, std::string>> items_;
};
} // namespace molo::anthropic::admin