The strings in the recreator stack item and several local stacks were changed to standard strings along with the recreator output string. The QString::append function was previously used to append to these strings. The std::string class also has an append function but it does not support a single character argument (though does support a count with the single character). Use of append function was replaced with the addition assignment operator (+=).
The append and top append functions of the recreator are still used by the various external recreate functions. Unlike with QString where a plain character is implicitly converted to a QChar, which then implicitly converted to a QString, the std::string class does not have similar functionality. For the same functionality, additional append and top append functions were added that take a plain character argument. All of the append functions use the addition assignment to append to the strings.
The append and top append functions, along with the pop with operands function, were changed to take a string rvalue reference argument (std::string &&). In most cases, the argument given to these functions is a temporary value, which using this type moves the temporary value to the function instead of copying the value. In other cases, the variable passed was no longer needed and was going out of scope, so the variable is passed via the std::move function. The advantage with using an rvalue reference argument is that it requires a temporary, so an error is given when the argument not a temporary value or the variable is not moved.
There are several cases in the recreator functions where values are obtained from the table. Since the table functions are still returning QString values, a call to the toStdString function was added.
The constant string recreate function used the QString::replace function that substitutes all instances of a particular character with a string. This function was used to convert all of the double quote characters in the constant to two double quote characters. There is no equivalent easy to use standard function to do the same thing. A range-for statement was added to iterate though the string making a copy into a local string. For each double quote character added, a second double quote is added.
The recreator contained an output is empty access function, for determining if the output string was empty, and a output last character function, for returning the last character added to the output string. These functions were only used by the remark recreate function to check if the last character added to a non-empty output was not a space (to see is a space should be added before the REM operator). These functions were replaced with the single back is not space function.
[branch recreator commit 56b40e3411]
Monday, November 10, 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)