本文整理汇总了C++中CubitString::get_at方法的典型用法代码示例。如果您正苦于以下问题:C++ CubitString::get_at方法的具体用法?C++ CubitString::get_at怎么用?C++ CubitString::get_at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CubitString
的用法示例。
在下文中一共展示了CubitString::get_at方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clean
CubitStatus RefEntityName::clean(CubitString &raw_name)
{
if (raw_name == "")
return CUBIT_FAILURE;
// A valid name consists of alphanumeric characters plus '.', '_', '-', or '@'
CubitStatus found_invalid_character = CUBIT_FAILURE;
// Initial character must be alphabetic or "_".
char c = raw_name.get_at(0);
if (!is_valid_first_char(c)) {
if (is_valid_first_char(get_character("replace")))
raw_name.put_at(0, get_character("replace"));
else
raw_name.put_at(0, '_');
found_invalid_character = CUBIT_SUCCESS;
}
for (unsigned int i = 1; i < raw_name.length(); i++) {
c = raw_name.get_at(i);
if (!is_valid_char(c)) {
found_invalid_character = CUBIT_SUCCESS;
raw_name.put_at(i, get_character("replace"));
}
}
return found_invalid_character;
}
示例2: get_character
char RefEntityName::get_character(const CubitString& type) const
{
if (type.get_at(0) == 'R' || type.get_at(0) == 'r')
return replacementCharacter;
else if (type.get_at(0) == 'S' || type.get_at(0) == 's')
return suffixCharacter;
else {
PRINT_ERROR("Invalid character type '%s', must be "
"'replacement' or 'suffix'\n", type.c_str());
return '#';
}
}
示例3: set_character
void RefEntityName::set_character(char rep, const CubitString &type)
{
if (is_valid_char(rep)) {
if (type.get_at(0) == 'R' || type.get_at(0) == 'r')
replacementCharacter = rep;
else if (type.get_at(0) == 'S' || type.get_at(0) == 's')
suffixCharacter = rep;
else
PRINT_ERROR("Invalid character type '%s', must be "
"'replacement' or 'suffix'\n", type.c_str());
} else {
PRINT_ERROR("Character '%c' is not a valid entity name character\n",
rep);
}
}
示例4: generate_unique_name
CubitStatus RefEntityName::generate_unique_name(CubitString &name)
{
// The method used to generate a unique name is to append
// 'suffixCharacter' and
// a letter from A-Z, a-z, or 0-9 to the end of name.
// If none of these produce a unique name, CUBIT_FALSE is returned.
CubitString alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
CubitString suffix(" ");
suffix.put_at(0, suffixCharacter);
CubitString internal = name;
// See if there is an suffixCharacter sign in name already. If so, is it
// the second to the last character in the string.
if (name.length() < 2 ||
name.get_at(name.length()-2) != suffixCharacter) {
// Name does not contain suffixCharacter at correct location, add one on.
internal += suffix;
}
CubitStatus found_unique = CUBIT_FAILURE;
int continue_trying = CUBIT_TRUE;
while (!found_unique && continue_trying) {
continue_trying = CUBIT_FALSE;
int name_length = internal.length();
unsigned int number_tested = 0;
for (unsigned int i=0; i < alphabet.length(); i++) {
internal.put_at(name_length-1, (char)alphabet.get_at(i));
if (!nameEntityList.move_to(internal)) {
found_unique = CUBIT_SUCCESS;
break;
}
number_tested++;
}
if (number_tested == alphabet.length()) {
// All suffixes used. Add another suffixCharacter and try again
// Name will look like '[email protected]@1' or '[email protected]@@1'...
// Find LAST suffixCharacter in name
int ch;
for (ch = (int)(internal.length())-1; ch >= 0; ch--) {
if (internal.get_at(ch) == suffixCharacter) {
break;
}
}
if (internal.get_at(ch) == suffixCharacter) {
// Add another suffixCharacter at ch+1
// Assured that position ch+1 exists or we wouldn't be here
internal.put_at(ch+1, suffixCharacter);
if (ch+2 < (int)internal.length())
internal.put_at(ch+2, ' ');
else
internal += " ";
continue_trying = CUBIT_TRUE;
}
}
}
if (found_unique)
name = internal;
return found_unique;
}