chromium/net/third_party/quiche/overrides/quiche_platform_impl/quiche_command_line_flags_impl.h

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_COMMAND_LINE_FLAGS_IMPL_H_
#define NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_COMMAND_LINE_FLAGS_IMPL_H_

#include <optional>
#include <string>
#include <vector>

#include "base/command_line.h"
#include "base/export_template.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "net/third_party/quiche/src/quiche/common/platform/api/quiche_export.h"
#include "net/third_party/quiche/src/quiche/common/platform/api/quiche_flags.h"

namespace quiche {

// Abstract class for setting flags and fetching help strings.
class QuicheFlagHelper {};

// Templated class for setting flags of various types.
template <typename T>
class TypedQuicheFlagHelper : public QuicheFlagHelper {};

// SetFlag specializations. Implementations in .cc file.
template <>
bool TypedQuicheFlagHelper<bool>::SetFlag(const std::string&) const;
template <>
bool TypedQuicheFlagHelper<uint16_t>::SetFlag(const std::string&) const;
template <>
bool TypedQuicheFlagHelper<int32_t>::SetFlag(const std::string&) const;
template <>
bool TypedQuicheFlagHelper<std::string>::SetFlag(const std::string&) const;

// TypedQuicheFlagHelper instantiations are in .cc file.
extern template class TypedQuicheFlagHelper<bool>;
extern template class TypedQuicheFlagHelper<uint16_t>;
extern template class TypedQuicheFlagHelper<int32_t>;
extern template class TypedQuicheFlagHelper<std::string>;

// Registry of QuicheFlagHelpers.
class QuicheFlagRegistry {};

// Class instantiated in DEFINE_QUIC_COMMAND_LINE_FLAG_IMPL macro expansion,
// that registers flag as a side effect of its constructor. Similar in spirit to
// absl::flags_internal::FlagRegistrar.
template <typename T>
class QuicheFlagSetup {};

// ------------------------------------------------------------------------
// DEFINE_QUICHE_COMMAND_LINE_FLAG implementation.
// ------------------------------------------------------------------------

#define DEFINE_QUICHE_COMMAND_LINE_FLAG_IMPL(type, name, default_value, help)

std::vector<std::string> QuicheParseCommandLineFlagsImpl(
    const char* usage,
    int argc,
    const char* const* argv);

// Used internally by QuicheParseCommandLineFlagsImpl(), but exposed here for
// testing.
struct QuicheParseCommandLineFlagsResult {};

QuicheParseCommandLineFlagsResult QuicheParseCommandLineFlagsHelper(
    const char* usage,
    const base::CommandLine& command_line);

void QuichePrintCommandLineFlagHelpImpl(const char* usage);

template <typename T>
T GetQuicheCommandLineFlag(const T& flag) {}

}  // namespace quiche

#endif  // NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_COMMAND_LINE_FLAGS_IMPL_H_