1
0
mirror of https://github.com/deavmi/birchwood synced 2024-09-20 11:43:22 +02:00

Merge branch 'params_parsing'

This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-17 09:31:17 +02:00
commit a1b739e8b7
2 changed files with 37 additions and 15 deletions

View File

@ -139,22 +139,25 @@ public class Client : Thread
if(commandReply.getReplyType() == ReplyType.RPL_BOUNCE)
{
logger.log();
logger.log("<<<>>>");
// TODO: Testing code was here
// logger.log();
// logger.log("<<<>>>");
logger.log("Take a look:\n\n"~commandReply.getParams());
// logger.log("Take a look:\n\n"~commandReply.getParams());
logger.log("And here is key-value pairs: ", commandReply.getKVPairs());
logger.log("And here is array: ", commandReply.getPairs());
// logger.log("And here is key-value pairs: ", commandReply.getKVPairs());
// logger.log("And here is array: ", commandReply.getPairs());
// TODO: DLog bug, this prints nothing
logger.log("And here is trailing: ", commandReply.getTrailing().length);
// // TODO: DLog bug, this prints nothing
// logger.log("And here is trailing: ", commandReply.getTrailing());
import std.stdio;
writeln("Trailer: "~commandReply.getTrailing());
// import std.stdio;
// writeln("Trailer: "~commandReply.getTrailing());
logger.log("<<<>>>");
logger.log();
// writeln(cast(ubyte[])commandReply.getTrailing());
// logger.log("<<<>>>");
// logger.log();

View File

@ -279,17 +279,35 @@ public final class Message
return params;
}
/**
* Retrieves the trailing text in the paramaters
* (if any)
*
* Returns: the trailing text
*/
public string getTrailing()
{
return ppTrailing;
}
/**
* Returns the parameters excluding the trailing text
* which are seperated by spaces but only those
* which are key-value pairs
*
* Returns: the key-value pair parameters
*/
public string[string] getKVPairs()
{
return ppKVPairs;
}
/**
* Returns the parameters excluding the trailing text
* which are seperated by spaces
*
* Returns: the parameters
*/
public string[] getPairs()
{
return ppPairs;
@ -300,10 +318,13 @@ public final class Message
private string[] ppPairs;
unittest
version(unittest)
{
import std.stdio;
}
unittest
{
string testInput = "A:=1 A=2 :Hello this is text";
writeln("Input: ", testInput);
@ -323,8 +344,6 @@ public final class Message
unittest
{
import std.stdio;
string testInput = ":Hello this is text";
bool hasTrailer;
string[] splitted = splitting(testInput, hasTrailer);