Spaces:
Sleeping
Sleeping
// Copyright 2016 Google Inc. | |
// | |
// 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.! | |
typedef int8_t int8; | |
typedef int16_t int16; | |
typedef int32_t int32; | |
typedef int64_t int64; | |
typedef uint8_t uint8; | |
typedef uint16_t uint16; | |
typedef uint32_t char32; | |
typedef uint32_t uint32; | |
typedef uint64_t uint64; | |
static constexpr uint32 kUnicodeError = 0xFFFD; | |
template <typename T, size_t N> | |
char (&ArraySizeHelper(T (&array)[N]))[N]; | |
template <typename T, size_t N> | |
char (&ArraySizeHelper(const T (&array)[N]))[N]; | |
namespace sentencepiece { | |
namespace util { | |
inline uint32 Swap32(uint32 x) { return __builtin_bswap32(x); } | |
} // namespace util | |
namespace error { | |
void Abort(); | |
void Exit(int code); | |
void SetTestCounter(int c); | |
void ResetTestMode(); | |
bool GetTestCounter(); | |
class Die { | |
public: | |
explicit Die(bool die) : die_(die) {} | |
~Die() { | |
std::cerr << std::endl; | |
if (die_) { | |
Abort(); | |
} | |
} | |
int operator&(std::ostream &) { return 0; } | |
private: | |
bool die_; | |
}; | |
} // namespace error | |
namespace logging { | |
enum LogSeverity { | |
LOG_INFO = 0, | |
LOG_WARNING = 1, | |
LOG_ERROR = 2, | |
LOG_FATAL = 3, | |
LOG_SEVERITY_SIZE = 4, | |
}; | |
int GetMinLogLevel(); | |
void SetMinLogLevel(int v); | |
inline const char *BaseName(const char *path) { | |
const char *p = strrchr(path, '\\'); | |
const char *p = strrchr(path, '/'); | |
if (p == nullptr) return path; | |
return p + 1; | |
} | |
} // namespace logging | |
} // namespace sentencepiece | |