Add CString::fromPointer()

This commit is contained in:
Eryn Wells 2016-04-17 16:49:50 -04:00
parent e58c29e15d
commit a3901330cd
2 changed files with 17 additions and 0 deletions

View file

@ -159,6 +159,17 @@ fromUnsignedInteger(u64 value,
}
usize
fromPointer(void* value,
char* buffer,
usize length,
u8 base,
bool capitalized)
{
return fromUnsignedInteger(uptr(value), buffer, length, base, capitalized);
}
char*
fromBool(bool value,
char* str,

View file

@ -6,6 +6,9 @@
* Utilities for dealing with C strings.
*/
#ifndef __KSTD_CSTRING_HH__
#define __KSTD_CSTRING_HH__
#include "Types.hh"
namespace kstd {
@ -46,6 +49,7 @@ void uppercase(char *str);
*/
usize fromInteger(i64 value, char* buffer, usize length, u8 base = 10, bool capitalized = false);
usize fromUnsignedInteger(u64 value, char* buffer, usize length, u8 base = 10, bool capitalized = false);
usize fromPointer(void* value, char* buffer, usize length, u8 base = 10, bool capitalized = false);
/** @} */
/** Convert a bool to a string. */
@ -55,3 +59,5 @@ char* fromBool(bool value, char* str, usize length);
} /* namespace CString */
} /* namespace kstd */
#endif /* __KSTD_CSTRING_HH__ */