File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,9 +14,14 @@ const QRegularExpression DiceRoll::completeStringRegEx_ =
1414 " (?<" +signString_+" >[+-]?)[\\ s\\ t]*" // / sign of first roll
1515 " (((?<" +numString_+" >\\ d+)?(?<" +diceString_+" >d))?(?<" +valueString_+" >\\ d+))[\\ s\\ t]*" // / dice of first roll
1616 " (\\ ((?<" +nameString_+" >.*?)\\ ))?[\\ s\\ t]*" // / name of first roll
17- " (?<" +remainingString_+" >[+-][\\ s\\ t]*((\\ d+)?(d))?(\\ d+)[\\ s\\ t]*(.*?)[\\ s\\ t]*?)*" // /remaining rolls
17+ " (?<" +remainingString_+" >( [+-][\\ s\\ t]*((\\ d+)?(d))?(\\ d+)[\\ s\\ t]*(.*?)[\\ s\\ t]*?)*) " // /remaining rolls
1818 " $" );
1919
20+ QString DiceRoll::rawString () const
21+ {
22+ return rawString_;
23+ }
24+
2025DiceRoll::DiceRoll ()
2126{
2227 valid_ = false ;
@@ -25,6 +30,7 @@ DiceRoll::DiceRoll()
2530DiceRoll::DiceRoll (const QString& diceRollString)
2631 : DiceRoll()
2732{
33+ rawString_ = diceRollString;
2834 QString currentString = diceRollString;
2935 auto matches = completeStringRegEx_.match (currentString);
3036 if (!matches.hasMatch ())
@@ -48,6 +54,11 @@ DiceRoll::DiceRoll(const QString& diceRollString)
4854 }
4955}
5056
57+ bool DiceRoll::valid () const
58+ {
59+ return valid_;
60+ }
61+
5162QString DiceRoll::roll () const
5263{
5364 QString result = name_ + " :" ;
Original file line number Diff line number Diff line change @@ -21,13 +21,15 @@ class DiceRoll
2121 bool valid_;
2222 QString name_;
2323 QVector<DiceRollEntry> rolls_;
24+ QString rawString_;
2425public:
2526 DiceRoll ();
2627 DiceRoll (const QString& diceRollString);
2728
2829 bool valid () const ;
2930 DiceRoll operator +(const DiceRoll& other);
3031 QString roll () const ;
32+ QString rawString () const ;
3133};
3234
3335#endif // DICEROLL_H
You can’t perform that action at this time.
0 commit comments