本文整理汇总了C++中KVString::Index方法的典型用法代码示例。如果您正苦于以下问题:C++ KVString::Index方法的具体用法?C++ KVString::Index怎么用?C++ KVString::Index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KVString
的用法示例。
在下文中一共展示了KVString::Index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FormatStructureName
void KVGeoNavigator::FormatStructureName(const Char_t* type, Int_t number, KVString& name)
{
// If a format for naming structures of given type has been defined by a call
// to SetStructureNameFormat(const Char_t *, const Char_t *), we use it to
// format the name in the TString.
// If no format was given, we use by default "[type]_[number]"
// If SetNameCorrespondanceList(const Char_t *) was used, we use it to translate
// any names resulting from this formatting to their final value.
name = "";
if (fStrucNameFmt.HasParameter(type)) {
KVString fmt = fStrucNameFmt.GetStringValue(type);
fmt.Begin("$");
while (!fmt.End()) {
KVString bit = fmt.Next();
if (bit.BeginsWith("type")) {
Ssiz_t ind = bit.Index("%");
if (ind > -1) {
bit.Remove(0, ind);
name += Form(bit.Data(), type);
} else
name += type;
} else if (bit.BeginsWith("number")) {
Ssiz_t ind = bit.Index("%");
if (ind > -1) {
bit.Remove(0, ind);
name += Form(bit.Data(), number);
} else
name += number;
} else
name += bit;
}
} else
name.Form("%s_%d", type, number);
TString tmp;
GetNameCorrespondance(name.Data(), tmp);
name = tmp;
}
示例2: FormatDetectorName
void KVGeoNavigator::FormatDetectorName(const Char_t* basename, KVString& name)
{
// If a format for naming detectors has been defined by a call
// to SetDetectorNameFormat(const Char_t *), we use it to
// format the name in the TString.
// If no format was given we prefix the names of the parent structures
// to the basename in order to generate the full name of the detector:
// [struc1-name]_[struc2-name]_..._[detector-basename]
// If SetNameCorrespondanceList(const Char_t *) was used, we use it to translate
// any names resulting from this formatting to their final value.
name = "";
if (!fCurStrucNumber) {
// no parent structures
name = basename;
} else {
if (fDetNameFmt == "") {
for (int i = 0; i < fCurStrucNumber; i++) {
KVGeoStrucElement* el = (KVGeoStrucElement*)fCurrentStructures[i];
name += Form("%s_", el->GetName());
}
name += basename;
} else {
// $det:name$ - will be replaced by the detector basename
// $struc:[type]:name$ - will be replaced by the name of the parent structure of given type
// $struc:[type]:type$ - will be replaced by the type of the parent structure of given type
// $struc:[type]:number$ - will be replaced by the number of the parent structure of given type
fDetNameFmt.Begin("$");
while (!fDetNameFmt.End()) {
KVString bit = fDetNameFmt.Next();
if (bit.Contains(":")) {
bit.Begin(":");
KVString itbit = bit.Next();
if (itbit == "det") {
itbit = bit.Next();
if (itbit.BeginsWith("name")) {
Ssiz_t ind = itbit.Index("%");
if (ind > -1) {
itbit.Remove(0, ind);
name += Form(itbit.Data(), basename);
} else
name += basename;
}
} else if (itbit == "struc") {
KVString struc_typ = bit.Next();
KVGeoStrucElement* el = 0;
for (int i = 0; i < fCurStrucNumber; i++) {
el = (KVGeoStrucElement*)fCurrentStructures[i];
if (el->IsType(struc_typ)) break;
}
if (el) {
itbit = bit.Next();
if (itbit.BeginsWith("name")) {
Ssiz_t ind = itbit.Index("%");
if (ind > -1) {
itbit.Remove(0, ind);
name += Form(itbit.Data(), el->GetName());
} else
name += el->GetName();
} else if (itbit.BeginsWith("type")) {
Ssiz_t ind = itbit.Index("%");
if (ind > -1) {
itbit.Remove(0, ind);
name += Form(itbit.Data(), el->GetType());
} else
name += el->GetType();
} else if (itbit.BeginsWith("number")) {
Ssiz_t ind = itbit.Index("%");
if (ind > -1) {
itbit.Remove(0, ind);
name += Form(itbit.Data(), el->GetNumber());
} else
name += el->GetNumber();
}
}
}
} else
name += bit;
}
}
}
TString tmp;
GetNameCorrespondance(name.Data(), tmp);
name = tmp;
}