folly/folly/cli/ProgramOptions.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/cli/ProgramOptions.h>

#include <unordered_map>
#include <unordered_set>

#include <boost/version.hpp>
#include <glog/logging.h>

#ifdef __ANDROID__
#include <gflags/gflags.h>
#endif

#include <folly/Conv.h>
#include <folly/Portability.h>
#include <folly/portability/GFlags.h>

po;

namespace folly {

namespace {

// Information about one GFlag. Handled via shared_ptr, as, in the case
// of boolean flags, two boost::program_options options (--foo and --nofoo)
// may share the same GFlag underneath.
//
// We're slightly abusing the boost::program_options interface; the first
// time we (successfully) parse a value that matches this GFlag, we'll set
// it and remember not to set it again; this prevents, for example, the
// default value of --foo from overwriting the GFlag if --nofoo is set.
template <class T>
class GFlagInfo {};

template <class T>
class GFlagValueSemanticBase : public po::value_semantic {};

template <class T>
void GFlagValueSemanticBase<T>::parse(
    boost::any& valueStore,
    const std::vector<std::string>& tokens,
    bool /* utf8 */) const {}

template <class T>
class GFlagValueSemantic : public GFlagValueSemanticBase<T> {};

class BoolGFlagValueSemantic : public GFlagValueSemanticBase<bool> {};

class NegativeBoolGFlagValueSemantic : public BoolGFlagValueSemantic {};

const std::string& getName(const std::string& name) {}

template <class T>
void addGFlag(
    gflags::CommandLineFlagInfo&& flag,
    po::options_description& desc,
    ProgramOptionsStyle style) {}

template <>
void addGFlag<bool>(
    gflags::CommandLineFlagInfo&& flag,
    po::options_description& desc,
    ProgramOptionsStyle style) {}

FlagAdder;

const std::unordered_map<std::string, FlagAdder> gFlagAdders =;

} // namespace

po::options_description getGFlags(ProgramOptionsStyle style) {}

namespace {

NestedCommandLineParseResult doParseNestedCommandLine(
    po::command_line_parser&& parser,
    const po::options_description& desc,
    boost::program_options::command_line_style::style_t style) {}

} // namespace

NestedCommandLineParseResult parseNestedCommandLine(
    int argc,
    const char* const argv[],
    const po::options_description& desc,
    boost::program_options::command_line_style::style_t style) {}

NestedCommandLineParseResult parseNestedCommandLine(
    const std::vector<std::string>& cmdline,
    const po::options_description& desc,
    boost::program_options::command_line_style::style_t style) {}

} // namespace folly