mirror of
https://github.com/deavmi/birchwood
synced 2024-09-20 15:02:53 +02:00
Messages
- Implemented `stripIllegalCharacters(string)` which provided an input string this will strip any illegal characters present within it
This commit is contained in:
parent
e833cf7a93
commit
06efa23c85
@ -146,13 +146,49 @@ public final class Message
|
|||||||
parameterParse();
|
parameterParse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Implement encoder function */
|
/**
|
||||||
|
* Encodes this `Message` into a CRLF delimited
|
||||||
|
* byte array
|
||||||
|
*
|
||||||
|
* If `ChecksMode` is set to `EASY` (default) then
|
||||||
|
* any invalid characters will be stripped prior
|
||||||
|
* to encoding
|
||||||
|
*
|
||||||
|
* Throws:
|
||||||
|
* `BirchwoodException` if `ChecksMode` is set to
|
||||||
|
* `HARDCORE` and invalid characters are present
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
public string encode()
|
public string encode()
|
||||||
{
|
{
|
||||||
string fullLine = from~" "~command~" "~params;
|
string fullLine = from~" "~command~" "~params;
|
||||||
return fullLine;
|
return fullLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provided an input string this will strip any illegal
|
||||||
|
* characters present within it
|
||||||
|
*
|
||||||
|
* Params:
|
||||||
|
* input = the string to filter
|
||||||
|
* Returns: the filtered string
|
||||||
|
*/
|
||||||
|
private static string stripIllegalCharacters(string input)
|
||||||
|
{
|
||||||
|
string stripped;
|
||||||
|
foreach(char character; input)
|
||||||
|
{
|
||||||
|
if(character == '\n' || character == '\r')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stripped ~= character;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stripped;
|
||||||
|
}
|
||||||
|
|
||||||
public static Message parseReceivedMessage(string message)
|
public static Message parseReceivedMessage(string message)
|
||||||
{
|
{
|
||||||
/* TODO: testing */
|
/* TODO: testing */
|
||||||
|
Loading…
Reference in New Issue
Block a user