7#ifndef RABIT_INTERNAL_UTILS_H_
8#define RABIT_INTERNAL_UTILS_H_
23#if !defined(__GNUC__) || defined(__FreeBSD__)
24#define fopen64 std::fopen
29#ifdef _FILE_OFFSET_BITS
30#if _FILE_OFFSET_BITS == 32
31#pragma message("Warning: FILE OFFSET BITS defined to be 32 bit")
37#define fopen64 std::fopen
55inline int CompareStringsCaseInsensitive(
const char* s1,
const char* s2) {
57 return _stricmp(s1, s2);
59 return strcasecmp(s1, s2);
64inline bool StringToBool(
const char* s) {
65 return CompareStringsCaseInsensitive(s,
"true") == 0 || atoi(s) != 0;
69inline void Printf(
const char *fmt, ...) {
79inline void Assert(
bool exp,
const char *fmt, ...) {
91inline void Check(
bool exp,
const char *fmt, ...) {
103inline void Error(
const char *fmt, ...) {
118auto Min(T
const& l, T
const& r) {
119 return l < r ? l : r;
123auto Max(T
const& l, T
const& r) {
124 return l > r ? l : r;
130inline T *BeginPtr(std::vector<T> &vec) {
131 if (vec.size() == 0) {
137inline char* BeginPtr(std::string &str) {
138 if (str.length() == 0)
return nullptr;
141inline const char*
BeginPtr(
const std::string &str) {
142 if (str.length() == 0)
return nullptr;
@ Max
"max" - take max on conflict
defines serializable interface of dmlc
defines console logging options for xgboost. Use to enforce unified print behavior.
T * BeginPtr(std::vector< T > &vec)
safely get the beginning address of a vector
Definition base.h:284
void Error(const char *fmt,...)
report error message, same as check
Definition utils.h:103
void Check(bool exp, const char *fmt,...)
same as assert, but this is intended to be used as a message for users
Definition utils.h:91
void Printf(const char *fmt,...)
printf, prints messages to the console
Definition utils.h:69
void Assert(bool exp, const char *fmt,...)
assert a condition is true, use this to handle debug information
Definition utils.h:79
const int kPrintBuffer
error message buffer length
Definition utils.h:52
namespace of rabit
Definition engine.h:18
Macros common to all headers.