[A] Added more c++ funcions
This commit is contained in:
@@ -107,6 +107,17 @@ SOFTWARE.
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* RETURN CODES
|
||||
* ***************************************************************************/
|
||||
typedef int fort_status_t;
|
||||
#define FT_SUCCESS 0
|
||||
#define FT_MEMORY_ERROR -1
|
||||
#define FT_ERROR -2
|
||||
#define FT_EINVAL -3
|
||||
#define IS_SUCCESS(arg) ((arg) >= 0)
|
||||
#define IS_ERROR(arg) ((arg) < 0)
|
||||
|
||||
|
||||
/*
|
||||
* Wchar support
|
||||
|
@@ -54,9 +54,11 @@ public:
|
||||
template <typename T>
|
||||
FTable &operator<<(const T &arg)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << arg;
|
||||
ft_nwrite(table, 1, stream.str().c_str());
|
||||
if (stream.tellp()) {
|
||||
ft_nwrite(table, 1, stream.str().c_str());
|
||||
stream = std::stringstream{};
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -71,10 +73,44 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool write(const char *str)
|
||||
{
|
||||
return IS_SUCCESS(ft_write(table, str));
|
||||
}
|
||||
|
||||
bool write_ln(const char *str)
|
||||
{
|
||||
return IS_SUCCESS(ft_write_ln(table, str));
|
||||
}
|
||||
|
||||
bool write(const std::string &str)
|
||||
{
|
||||
return write(str.c_str());
|
||||
}
|
||||
|
||||
bool write_ln(const std::string &str)
|
||||
{
|
||||
return write_ln(str.c_str());
|
||||
}
|
||||
|
||||
template <typename T, typename ...Ts>
|
||||
bool write(const T &arg, const Ts &...args)
|
||||
{
|
||||
return write(arg) && write(args...);
|
||||
}
|
||||
|
||||
template <typename T, typename ...Ts>
|
||||
bool write_ln(const T &arg, const Ts &...args)
|
||||
{
|
||||
if (sizeof...(args) == 0)
|
||||
return write_ln(arg);
|
||||
return write(arg) && write_ln(args...);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
FTABLE *table;
|
||||
std::stringstream stream;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user