*
* Does not throw.
*/
-bool inline isNullOrEmpty(const char *str)
+static inline bool isNullOrEmpty(const char *str)
{
return str == NULL || str[0] == '\0';
}
* Returns true if \p prefix is empty.
* Does not throw.
*/
-bool inline startsWith(const std::string &str, const std::string &prefix)
+static inline bool startsWith(const std::string &str, const std::string &prefix)
{
return str.compare(0, prefix.length(), prefix) == 0;
}
//! \copydoc startsWith(const std::string &, const std::string &)
-bool inline startsWith(const char *str, const char *prefix)
+static inline bool startsWith(const char *str, const char *prefix)
{
return std::strncmp(str, prefix, std::strlen(prefix)) == 0;
}
* Returns true if \p suffix is NULL or empty.
* Does not throw.
*/
-bool endsWith(const std::string &str, const char *suffix);
+bool endsWith(const char *str, const char *suffix);
+//! \copydoc endsWith(const char *, const char *)
+static inline bool endsWith(const std::string &str, const char *suffix)
+{
+ return endsWith(str.c_str(), suffix);
+}
/*! \brief
* Removes a suffix from a string.
* - No maximum line width (only explicit line breaks).
* - No indentation.
* - No continuation characters.
- * - Ignore whitespace after an explicit newline.
+ * - Do not keep final spaces in input strings.
*/
TextLineWrapperSettings();
*/
void setFirstLineIndent(int indent) { firstLineIndent_ = indent; }
/*! \brief
- * Sets whether to remove spaces after an explicit newline.
+ * Sets whether final spaces in input should be kept.
*
- * \param[in] bStrip If true, spaces after newline are ignored.
+ * \param[in] bKeep Whether to keep spaces at the end of the input.
*
- * If not removed, the space is added to the indentation set with
- * setIndent().
- * The default is to not strip such whitespace.
+ * This means that wrapping a string that ends in spaces also keeps
+ * those spaces in the output. This allows using the wrapper for
+ * partial lines where the initial part of the line may end in a space.
+ * By default, all trailing whitespace is removed. Note that this
+ * option does not affect spaces before an explicit newline: those are
+ * always removed.
*/
- void setStripLeadingWhitespace(bool bStrip)
- {
- bStripLeadingWhitespace_ = bStrip;
- }
+ void setKeepFinalSpaces(bool bKeep) { bKeepFinalSpaces_ = bKeep; }
/*! \brief
* Sets a continuation marker for wrapped lines.
*
* If -1, \a indent_ is used.
*/
int firstLineIndent_;
- //! Whether to ignore or preserve space after a newline.
- bool bStripLeadingWhitespace_;
+ //! Whether to keep spaces at end of input.
+ bool bKeepFinalSpaces_;
//! If not \c '\0', mark each wrapping point with this character.
char continuationChar_;
*/
TextLineWrapperSettings &settings() { return settings_; }
+ //! Returns true if the wrapper would not modify the input string.
+ bool isTrivial() const;
+
/*! \brief
* Finds the next line to be wrapped.
*