folly/folly/String.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/String.h>

#include <cctype>
#include <cerrno>
#include <cstdarg>
#include <cstring>
#include <iterator>
#include <sstream>
#include <stdexcept>

#include <glog/logging.h>

#include <folly/Portability.h>
#include <folly/ScopeGuard.h>
#include <folly/container/Array.h>

namespace folly {

static_assert;
static_assert;
static_assert;
static_assert;
static_assert;

namespace detail {

struct string_table_c_escape_make_item {};

struct string_table_c_unescape_make_item {};

struct string_table_hex_make_item {};

struct string_table_uri_escape_make_item {};

FOLLY_STORAGE_CONSTEXPR decltype(cEscapeTable) cEscapeTable =;
FOLLY_STORAGE_CONSTEXPR decltype(cUnescapeTable) cUnescapeTable =;
FOLLY_STORAGE_CONSTEXPR decltype(hexTable) hexTable =;
FOLLY_STORAGE_CONSTEXPR decltype(uriEscapeTable) uriEscapeTable =;

} // namespace detail

static inline bool is_oddspace(char c) {}

StringPiece ltrimWhitespace(StringPiece sp) {}

StringPiece rtrimWhitespace(StringPiece sp) {}

namespace {

int stringAppendfImplHelper(
    char* buf, size_t bufsize, const char* format, va_list args) {}

void stringAppendfImpl(std::string& output, const char* format, va_list args) {}

} // namespace

std::string stringPrintf(const char* format, ...) {}

std::string stringVPrintf(const char* format, va_list ap) {}

// Basic declarations; allow for parameters of strings and string
// pieces to be specified.
std::string& stringAppendf(std::string* output, const char* format, ...) {}

std::string& stringVAppendf(
    std::string* output, const char* format, va_list ap) {}

void stringPrintf(std::string* output, const char* format, ...) {}

void stringVPrintf(std::string* output, const char* format, va_list ap) {}

namespace {

struct PrettySuffix {};

const PrettySuffix kPrettyTimeSuffixes[] =;

const PrettySuffix kPrettyTimeHmsSuffixes[] =;

const PrettySuffix kPrettyBytesMetricSuffixes[] =;

const PrettySuffix kPrettyBytesBinarySuffixes[] =;

const PrettySuffix kPrettyBytesBinaryIECSuffixes[] =;

const PrettySuffix kPrettyUnitsMetricSuffixes[] =;

const PrettySuffix kPrettyUnitsBinarySuffixes[] =;

const PrettySuffix kPrettyUnitsBinaryIECSuffixes[] =;

const PrettySuffix kPrettySISuffixes[] =;

const PrettySuffix* const kPrettySuffixes[PRETTY_NUM_TYPES] =;

} // namespace

std::string prettyPrint(double val, PrettyType type, bool addSpace) {}

// TODO:
// 1) Benchmark & optimize
double prettyToDouble(
    folly::StringPiece* const prettyString, const PrettyType type) {}

double prettyToDouble(folly::StringPiece prettyString, const PrettyType type) {}

std::string hexDump(const void* ptr, size_t size) {}

// There are two variants of `strerror_r` function, one returns
// `int`, and another returns `char*`. Selecting proper version using
// preprocessor macros portably is extremely hard.
//
// For example, on Android function signature depends on `__USE_GNU` and
// `__ANDROID_API__` macros (https://git.io/fjBBE).
//
// So we are using C++ overloading trick: we pass a pointer of
// `strerror_r` to `invoke_strerror_r` function, and C++ compiler
// selects proper function.

[[maybe_unused]] static std::string invoke_strerror_r(
    int (*strerror_r)(int, char*, size_t), int err, char* buf, size_t buflen) {}

[[maybe_unused]] static std::string invoke_strerror_r(
    char* (*strerror_r)(int, char*, size_t),
    int err,
    char* buf,
    size_t buflen) {}

std::string errnoStr(int err) {}

namespace {

void toLowerAscii8(char& c) {}

void toLowerAscii32(uint32_t& c) {}

void toLowerAscii64(uint64_t& c) {}

} // namespace

void toLowerAscii(char* str, size_t length) {}

namespace detail {

size_t hexDumpLine(
    const void* ptr, size_t offset, size_t size, std::string& line) {}

} // namespace detail

std::string stripLeftMargin(std::string s) {}

} // namespace folly

#ifdef FOLLY_DEFINED_DMGL
#undef FOLLY_DEFINED_DMGL
#undef DMGL_NO_OPTS
#undef DMGL_PARAMS
#undef DMGL_ANSI
#undef DMGL_JAVA
#undef DMGL_VERBOSE
#undef DMGL_TYPES
#undef DMGL_RET_POSTFIX
#endif