module watt.conv

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 { }
class ConvException : Exception

Thrown when a conversion fails.

fn toLower(s: scope (StrArg)) string

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%"
fn toUpper(s: scope (StrArg)) string

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"
fn toUlong(s: const(char)[], base: i32) u64

Parse s as an integer, and return it as a u64.

Parameters

s

The string to convert.

base

The base of s. 10 is the default.

Throws

  • ConvException if s could not be converted.

fn toLong(s: const(char)[], base: i32) i64

Parse s as an integer, and return it as an i64.

Parameters

s

The string to convert.

base

The base of s. 10 is the default.

Throws

  • ConvException if s could not be converted.

fn toInt(s: const(char)[], base: i32) i32

Parse s as an integer, and return it as an i32.

Parameters

s

The string to convert.

base

The base of s. 10 is the default.

Throws

  • ConvException if s could not be converted.

fn toUint(s: const(char)[], base: i32) u32

Parse s as an integer, and return it as a u32.

Parameters

s

The string to convert.

base

The base of s. 10 is the default.

Throws

  • ConvException if s could not be converted.

fn toString(val: u8) string

Get a string from a given u8.

Examples

toString(32);  // returns "32"
fn toString(val: i8) string

Return an i8 as a string.

fn toString(val: u16) string

Return a u16 as a string.

fn toString(val: i16) string

Return an i16 as a string.

fn toString(val: u32) string

Return a u32 as a string.

fn toString(val: i32) string

Return an i32 as a string.

fn toString(val: u64) string

Return a u64 as a string.

fn toString(val: i64) string

Return an i64 as a string.

fn toString(f: f32) string

Return an f32 as a string.

fn toString(f: f64) string

Return an f64 as a string.

fn toString(p: void*) string

Return a pointer as a string.

fn toString(b: bool) string

Return a bool as "true" or "false".

fn toStringHex(val: u64) string

Returns an upper case hex string from the given unsigned long.

fn toStringBinary(val: u8) string

Given a u8, return a binary string.

fn toStringBinary(val: u16) string

Given a u16, return a binary string.

fn toStringBinary(val: u32) string

Given a u32, return a binary string.

fn toStringBinary(val: u64) string

Given a u64, return a binary string.

fn toStringBinary(val: i8) string

Given an i8, return a binary string.

fn toStringBinary(val: i16) string

Given an i16, return a binary string.

fn toStringBinary(val: i32) string

Given an i32, return a binary string.

fn toStringBinary(val: i64) string

Given an i64, return a binary string.

fn toStringz(s: scope (SinkArg)) const(char)*

Given a Volt utf-8 string s, return a pointer to a null terminated string.

This is for interfacing with C libraries.

fn toStringz(s: const(wchar)[]) const(wchar)*

Given a Volt utf-16 string s, return a pointer to a null terminated wchar string.

This is for interfacing with win32 libraries.

fn toString(s: scope (const(scope (char)*)) string

Given a null terminated string s, return a Volt string.

fn toFloat(s: string) f32

Return a string as an f32.

fn toDouble(s: string) f64

Return a string as an f64.