chromium/third_party/spirv-tools/src/tools/util/flags.cpp

// Copyright (c) 2023 Google LLC.
//
// 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 "flags.h"

#include <cstdlib>
#include <cstring>
#include <iostream>
#include <regex>
#include <string>
#include <unordered_set>
#include <variant>
#include <vector>

namespace flags {

std::vector<std::string> positional_arguments;

namespace {

token_t;
token_iterator_t;

// Extracts the flag name from a potential token.
// This function only looks for a '=', to split the flag name from the value for
// long-form flags. Returns the name of the flag, prefixed with the hyphen(s).
inline std::string get_flag_name(const std::string& flag, bool is_short_flag) {}

// Parse a boolean flag. Returns `true` if the parsing succeeded, `false`
// otherwise.
bool parse_bool_flag(Flag<bool>& flag, bool is_short_flag,
                     const std::string& token) {}

// Parse a uint32_t flag value.
bool parse_flag_value(Flag<uint32_t>& flag, const std::string& value) {}

// "Parse" a string flag value (assigns it, cannot fail).
bool parse_flag_value(Flag<std::string>& flag, const std::string& value) {}

// Parse a potential multi-token flag. Moves the iterator to the last flag's
// token if it's a multi-token flag. Returns `true` if the parsing succeeded.
// The iterator is moved to the last parsed token.
template <typename T>
bool parse_flag(Flag<T>& flag, bool is_short_flag, const char*** iterator) {}

}  // namespace

// This is the function to expand if you want to support a new type.
bool FlagList::parse_flag_info(FlagInfo& info, token_iterator_t* iterator) {}

bool FlagList::parse(token_t* argv) {}

// Just the public wrapper around the parse function.
bool Parse(const char** argv) {}

}  // namespace flags