57 lines
1011 B
D
57 lines
1011 B
D
module structs;
|
|
|
|
private
|
|
{
|
|
import std.array;
|
|
import std.bitmanip;
|
|
import std.system;
|
|
|
|
/++
|
|
+ Supported format types
|
|
+/
|
|
enum FormatType
|
|
{
|
|
INT_8, /// Signed integer 8 bit
|
|
INT_16, /// Signed integer 16 bit
|
|
INT_32, /// Signed integer 32 bit
|
|
INT_64, /// Signed integer 64 bit
|
|
UINT_8, /// Unsigned integer 8 bit
|
|
UINT_16, /// Unsigned integer 16 bit
|
|
UINT_32, /// Unsigned integer 32 bit
|
|
UINT_64 /// Unsigned integer 64 bit
|
|
}
|
|
|
|
/++
|
|
+ A element of a package
|
|
+/
|
|
struct Element
|
|
{
|
|
Endian endian; /// The endian to use
|
|
bool isArray; /// If it's an array
|
|
size_t arraySize; /// Array size
|
|
FormatType formatType; /// The formated type
|
|
}
|
|
|
|
/++
|
|
+ Removes the whitespaces of the string.
|
|
+ Params:
|
|
+ source = The source string to format
|
|
+ Returns: String without whitespaces
|
|
+/
|
|
pure string remove_whitespaces(string source)
|
|
{
|
|
return source.replace(" ", "");
|
|
}
|
|
|
|
// Test remove whitespaces.
|
|
unittest
|
|
{
|
|
assert(remove_whitespaces(" a b c ") == "abc");
|
|
}
|
|
}
|
|
|
|
public
|
|
{
|
|
|
|
}
|