Skip to content

Commit

Permalink
libcore|String: Added a string conversion method
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 27, 2017
1 parent f260c8e commit a857fb1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doomsday/sdk/libcore/include/de/data/string.h
Expand Up @@ -299,6 +299,20 @@ class DENG2_PUBLIC String : public QString
*/
dint toInt(bool *ok = 0, int base = 10, IntConversionFlags flags = AllowOnlyWhitespace) const;

/**
* Converts the string to a 32-bit unsigned integer. The behavior is the same as
* QString::toUInt(), with the exception that the default is to autodetect the
* base of the number.
*
* @param ok @c true is returned via this pointer if the conversion was
* successful.
* @param base Base for the number.
*
* @return 32-bit unsigned integer parsed from the string (@c *ok set to true).
* @c 0 if the conversion fails (@c *ok set to @c false).
*/
duint32 toUInt32(bool *ok = 0, int base = 0) const;

/**
* Adds a prefix to each line in the text.
*
Expand Down
5 changes: 5 additions & 0 deletions doomsday/sdk/libcore/src/data/string.cpp
Expand Up @@ -539,6 +539,11 @@ dint String::toInt(bool *ok, int base, IntConversionFlags flags) const
return token.QString::toInt(ok, base);
}

duint32 String::toUInt32(bool *ok, int base) const
{
return QString::toUInt(ok, base);
}

String String::addLinePrefix(String const &prefix) const
{
String result;
Expand Down

0 comments on commit a857fb1

Please sign in to comment.