Gnats 5158: 6.1 column names in multislot table are missing last letter 2-8-2012 //======================================================= //+public // // METHOD: // void SimWorkspace::parseObjectName( QString& const fullName, // QString& aggName, // QString& objectName, // QString& accountName, // QString& slotName ) // // PURPOSE: // Given a fully qualified object name in the internal/valid format, // (i.e. containing "__dot__"), extract the components of the object // name, e.g. name of the aggregate. // The full name of an object is: aggregate:object^account.slot (using the // valid internal substitutes for "." ":" etc. // // PARAMETERS: // (I) fullName - full object name in internal/valid format ("__dot__") // (O) aggName - the name of the aggregate or "" if not in the name // (O) objectName - the name of the object // (O) accountName - the name of the account or "" if not in the name // (O) slotName - the name of the slot or "" if not in the name // // RETURN VALUES: // None // // PRECONDITIONS & ASSUMPTIONS: // This method assumes that the fullName is in the internal/valid format // and contains no invalid characters. // // This method assumes it is being passed an object name. If it is // passed an ordinary string it will return the original string value in // as the objectName and leave the other 3 attributes blank. If, however, // the ordinary string contains any of the separators in the internal format, // the behavior of this method is unclear. // // WARNINGS & SIDE EFFECTS: // None // //- // // DESIGN DETAILS: // Ideally, this method would return an error if is is given an ordinary string // instead of an object. But we have no way of distinguishing between an ordinary // string and an object that specifies only the object without an aggregate, account, // or slot. So we just return any invalid string in the objectName parameter. // void SimWorkspace::parseObjectName( const QString& fullName, QString& aggName, QString& objectName, QString& accountName, QString& slotName ) { // The separators we are replacing are: dot, colon, caret/carrot. // They will appear in our fullName string as multi-character strings // (like __dot__) QString dotSeparator = rwWorkspace->findSubstitutionForChar('.'); QString colonSeparator = rwWorkspace->findSubstitutionForChar(':'); QString caretSeparator = rwWorkspace->findSubstitutionForChar('^'); // The format is: // aggregate:object^account.slot int dotStart = fullName.indexOf(dotSeparator); int colonStart = fullName.indexOf(colonSeparator); int caretStart = fullName.indexOf(caretSeparator); // Since we know that an object will always have an object-name component, // but may not have any other components, the strategy is to work from // the outside-in, towards the object name, by moving endPos and startPos // towards the middle of the string. // startPos and endPos should always point to the first and last unparsed // characters in the string. int startPos = 0; int endPos = fullName.length()-1; // The slot name is all the text after the dot. // If we do not have a dot, we will not return a slot name. if (-1 != dotStart) { int slotStart = dotStart + dotSeparator.length(); slotName = fullName.mid(slotStart, endPos-slotStart+1); // endPos now points to the last unparsed character in the string endPos = dotStart-1; } else { // No accountName, so endPos still points to the last unparsed // character in the string. slotName = ""; } // The account name is the text between the caret and any slotname. // If a caret does not exist, we do not return an account name. if (-1 != caretStart) { int accountStart = caretStart + caretSeparator.length(); accountName = fullName.mid(accountStart, endPos-accountStart+1); // endPos now points to the last unparsed character in the string. endPos = caretStart-1; } else { // No accountName, so endPos still points to the end of the unparsed // portion of the string. accountName = ""; } // The aggregate is the text at the start of the string up to the colon // symbol. If the colon does not exist, then we do not return an aggregate. if (-1 != colonStart) { aggName = fullName.mid(startPos, colonStart-startPos-1); // startPos now points to the first unparsed character. startPos = colonStart + colonSeparator.length(); } else { // No aggName, so startPos still points to the first unparsed // character in the string. aggName = ""; } // The object name should always exist, so the object name is the text // between any aggregate and any account/slot names. if (startPos <= endPos) { objectName = fullName.mid(startPos, endPos-startPos+1); } else { // The order of the separators was incorrect, so return the entire // string as the object. objectName = fullName; } }