Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 2 (modified by landauf, 16 years ago) (diff)

String

TracNav(TracNav/TOC_Development)?

String defines several useful functions for string manipulation. The following list gives a short overview:

  • strip(string* pointer): Removes all whitespaces from a string. See getStripped for examples.
  • getStripped(string): Removes all whitespaces and returns the modified string.
    • Example: getStripped(" test abc\tabc test\nThis is a newline! ") = "testabcabctestThisisanewline!"
  • removeTrailingWhitespaces(string): Removes trailing whitespace and returns the modified string.
    • Example: removeTrailingWhitespaces(" test abc ") = "test abc"
  • getNextQuote(string, start): Returns the position of the next quote in the string, starting with start.
    • Examples:
      • getNextQuote("123\"567\"9", 0) = 4
      • getNextQuote("123\"567\"9", 4) = 4
      • getNextQuote("123\"567\"9", 6) = 8
      • getNextQuote("123\"567\"9", 9) = std::npos
  • isBetweenQuotes(string, position): Returns true if position is between two quotes.
    • Examples:
      • isBetweenQuotes("123\"567\"9", 1) = false
      • isBetweenQuotes("123\"567\"9", 4) = false
      • isBetweenQuotes("123\"567\"9", 5) = true
      • isBetweenQuotes("123\"567\"9", 8) = false
      • isBetweenQuotes("123\"567\"9", 9) = false
  • hasStringBetweenQuotes(string): Returns true if the string contains something like '…"between quotes"…'.
    • Examples:
      • hasStringBetweenQuotes("test") = false
      • hasStringBetweenQuotes("test\"abc") = false
      • hasStringBetweenQuotes("test\"abc\"") = true
  • getStringBetweenQuotes(string): If the string contains something like '…"between quotes"…' then 'between quotes' gets returned (without quotes).
    • Examples:
      • hasStringBetweenQuotes("test") = ""
      • hasStringBetweenQuotes("test\"abc") = ""
      • hasStringBetweenQuotes("test\"abc\"") = "abc"
  • stripEnclosingQuotes(string): Removes enclosing quotes if available (including whitespaces at the outside of the quotes).
    • Examples:
      • stripEnclosingQuotes(" \"hello!\" ") = "hello!"
      • stripEnclosingQuotes(" \"hello! ") = " \"hello! "
  • stripEnclosingBraces(string): Removes enclosing {braces} (braces must be exactly on the beginning and the end of the string).
    • Examples:
      • stripEnclosingBraces("{test}") = "test"
      • stripEnclosingBraces(" {test}") = " {test}"
      • stripEnclosingBraces("{ test }") = " test "
  • isEmpty(string):
  • isComment(string):
  • isNumeric(string):
  • addSlashes(string):
  • removeSlashes(string):
  • lowercase(string* pointer):
  • getLowercase(string):
  • uppercase(string* pointer):
  • getUppercase(string):
  • nocaseCmp(string1, string2):
  • nocaseCmp(string1, string2, length):
  • hasComment(string):
  • getComment(string):
  • getCommentPosition(string):
  • getNextCommentPosition(string, start):