src/Generic/common/LocatedString.cpp
/**
 * Each character's offset is set to the offset of the character immediately
 * to the left of <code>pos</code>, or immediately to the right of the
 * inserted text if it is inserted at the beginning of the string (i.e., if
 * <code>pos == 0</code>).
 *
 * For example:
 *
 * <pre>    ["smiles", {100,101,102,103,104,105}].insert("ix ", 1)
 *    =>
 *    ["six miles", {100,100,100,100,101,102,103,104,105}]</pre>
 *
 * <pre>    ["hazard", {100,101,102,103,104,105}].insert("hap", 0)
 *    =>
 *    ["haphazard", {100,100,100,100,101,102,103,104,105}]</pre>
 *
 * @param str the array of characters to insert into this string.
 * @param pos the position at which to insert the text.
 */
Each character's offset is set to the offset of the character immediately
to the left of pos, or immediately to the right of the
inserted text if it is inserted at the beginning of the string .

For example.





@param str the array of characters to insert into this string.
@param pos the position at which to insert the text.
Each character ' s offset is set to the offset of the character immediately to the left of pos or immediately to the right of the inserted text if it is inserted at the beginning of the string . For example . @param str the array of characters to insert into this string . @param pos the position at which to insert the text .
void LocatedString::insert(const wchar_t *str, int pos) {
	OffsetGroup new_offset;
	if (length() == 0) {
		SessionLogger::warn("located_string") << "inserting into an empty string.  Offsets will be undefined." << std::endl;
	} else if (pos == 0) {
		new_offset = _offsets.front().startOffset;
	} else {
		new_offset = endOffsetGroup(pos-1);
	}
	insert(str, pos, OffsetRange(new_offset, new_offset));
}
void LocatedString :: insert ( const wchar_t * str , int pos ) { OffsetGroup new_offset ; if ( length ( ) == 0 ) { SessionLogger :: warn ( " " ) << " " << std :: endl ; } else if ( pos == 0 ) { new_offset = _offsets . front ( ) . startOffset ; } else { new_offset = endOffsetGroup ( pos - 1 ) ; } insert ( str , pos , OffsetRange ( new_offset , new_offset ) ) ; }
Each character's offset is set to the offset of the character immediately
 to the left of <code>pos</code>, or immediately to the right of the
 inserted text if it is inserted at the beginning of the string (i.e., if
 <code>pos == 0</code>).
Each character ' s offset is set to the offset of the character immediately to the left of <code > pos< / code > or immediately to the right of the inserted text if it is inserted at the beginning of the string ( i . e . if <code > pos == 0< / code > ) .