Functions dealing with converting strings to integers, integers to strings, integers to different types of integers, and so on.
Code Map
//! Functions dealing with converting strings to integers, integers to
//! strings, integers to different types of integers, and so on.
module watt.conv;
//! Thrown when a conversion fails.
class ConvException : Exception
{
public:
this(msg: string) { }
}
//! Get the lowercase representation of a string.
fn toLower(s: scope (StrArg)) string { }
//! Get the uppercase representation of a string.
fn toUpper(s: scope (StrArg)) string { }
//! Parse s as an integer, and return it as a u64.
fn toUlong(s: const(char)[], base: i32) u64 { }
//! Parse s as an integer, and return it as an i64.
fn toLong(s: const(char)[], base: i32) i64 { }
//! Parse s as an integer, and return it as an i32.
fn toInt(s: const(char)[], base: i32) i32 { }
//! Parse s as an integer, and return it as a u32.
fn toUint(s: const(char)[], base: i32) u32 { }
//! Get a string from a given u8.
fn toString(val: u8) string { }
//! Return an i8 as a string.
fn toString(val: i8) string { }
//! Return a u16 as a string.
fn toString(val: u16) string { }
//! Return an i16 as a string.
fn toString(val: i16) string { }
//! Return a u32 as a string.
fn toString(val: u32) string { }
//! Return an i32 as a string.
fn toString(val: i32) string { }
//! Return a u64 as a string.
fn toString(val: u64) string { }
//! Return an i64 as a string.
fn toString(val: i64) string { }
//! Return an f32 as a string.
fn toString(f: f32) string { }
//! Return an f64 as a string.
fn toString(f: f64) string { }
//! Return a pointer as a string.
fn toString(p: void*) string { }
//! Return a bool as "true" or "false".
fn toString(b: bool) string { }
//! Returns an upper case hex string from the given unsigned long.
fn toStringHex(val: u64) string { }
//! Given a u8, return a binary string.
fn toStringBinary(val: u8) string { }
//! Given a u16, return a binary string.
fn toStringBinary(val: u16) string { }
//! Given a u32, return a binary string.
fn toStringBinary(val: u32) string { }
//! Given a u64, return a binary string.
fn toStringBinary(val: u64) string { }
//! Given an i8, return a binary string.
fn toStringBinary(val: i8) string { }
//! Given an i16, return a binary string.
fn toStringBinary(val: i16) string { }
//! Given an i32, return a binary string.
fn toStringBinary(val: i32) string { }
//! Given an i64, return a binary string.
fn toStringBinary(val: i64) string { }
//! Given a Volt utf-8 string s, return a pointer to a null terminated
//! string.
fn toStringz(s: scope (SinkArg)) const(char)* { }
//! Given a Volt utf-16 string s, return a pointer to a null terminated
//! wchar string.
fn toStringz(s: const(wchar)[]) const(wchar)* { }
//! Given a null terminated string s, return a Volt string.
fn toString(s: scope (const(scope (char)*)) string { }
//! Return a string as an f32.
fn toFloat(s: string) f32 { }
//! Return a string as an f64.
fn toDouble(s: string) f64 { }
Thrown when a conversion fails.
Get the lowercase representation of a string
.
If a character in s
can be represented as a lower case letter
of some description, it is replaced with such. Otherwise, it remains
intact.
Examples
toLower("APPLE"); // returns "apple"
toLower("BA(NA)NA 32%"); // returns "ba(na)na 32%"
Get the uppercase representation of a string
.
If a character in s
can be represented with an uppercase letter,
that letter is replaced with such. Otherwise, the character remains
intact.
Examples
toUpper("hellO THERE 32"); // returns "HELLO THERE 32"
Parse s
as an integer, and return it as a u64
.
Parameters
s |
The string to convert. |
base |
The base of |
Throws
-
ConvException
ifs
could not be converted.
Parse s
as an integer, and return it as an i64
.
Parameters
s |
The string to convert. |
base |
The base of |
Throws
-
ConvException
ifs
could not be converted.
Parse s
as an integer, and return it as an i32
.
Parameters
s |
The string to convert. |
base |
The base of |
Throws
-
ConvException
ifs
could not be converted.
Parse s
as an integer, and return it as a u32
.
Parameters
s |
The string to convert. |
base |
The base of |
Throws
-
ConvException
ifs
could not be converted.
Get a string from a given u8
.
Examples
toString(32); // returns "32"
Return an i8
as a string.
Return a u16
as a string.
Return an i16
as a string.
Return a u32
as a string.
Return an i32
as a string.
Return a u64
as a string.
Return an i64
as a string.
Return an f32
as a string.
Return an f64
as a string.
Return a pointer as a string.
Return a bool
as "true" or "false".
Returns an upper case hex string from the given unsigned long.
Given a u8
, return a binary string.
Given a u16
, return a binary string.
Given a u32
, return a binary string.
Given a u64
, return a binary string.
Given an i8
, return a binary string.
Given an i16
, return a binary string.
Given an i32
, return a binary string.
Given an i64
, return a binary string.
Given a Volt utf-8 string s, return a pointer to a null terminated string.
This is for interfacing with C libraries.
Given a Volt utf-16 string s, return a pointer to a null terminated wchar string.
This is for interfacing with win32 libraries.
Given a null terminated string s, return a Volt string.
Return a string as an f32
.
Return a string as an f64
.