1
0
mirror of https://github.com/deavmi/birchwood synced 2024-09-20 13:22:52 +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) if(commandReply.getReplyType() == ReplyType.RPL_BOUNCE)
{ {
logger.log(); // TODO: Testing code was here
logger.log("<<<>>>"); // 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 key-value pairs: ", commandReply.getKVPairs());
logger.log("And here is array: ", commandReply.getPairs()); // logger.log("And here is array: ", commandReply.getPairs());
// TODO: DLog bug, this prints nothing // // TODO: DLog bug, this prints nothing
logger.log("And here is trailing: ", commandReply.getTrailing().length); // logger.log("And here is trailing: ", commandReply.getTrailing());
import std.stdio; // import std.stdio;
writeln("Trailer: "~commandReply.getTrailing()); // writeln("Trailer: "~commandReply.getTrailing());
logger.log("<<<>>>"); // writeln(cast(ubyte[])commandReply.getTrailing());
logger.log();
// logger.log("<<<>>>");
// logger.log();

View File

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