src/CSLModels.cpp
CSLModel* CSLModelByPkgShortId (std::uint16_t _pkgHash,
                                const std::string& _shortId)
{
    // try finding the model by shortId, also verify pckage hash
    mapCSLModelTy::iterator iBest = glob.mapCSLModels.end();
    for (mapCSLModelTy::iterator iter = glob.mapCSLModels.begin();
         iter != glob.mapCSLModels.end();
         ++iter)
    {
        // short id matches...as far as known
        if (std::strncmp(iter->second.GetShortId().c_str(), _shortId.c_str(), _shortId.length()) == 0) {
            if (iter->second.pkgHash == _pkgHash) {     // perfect match!
                iBest = iter;
                break;
            }
            else if (iBest == glob.mapCSLModels.end() &&// remember the first model for which at least the short id matches
                     !iter->second.IsObjInvalid())
                iBest = iter;                           // but keep on searching
        }
    }
    
    // not found, or invalid?
    if (iBest == glob.mapCSLModels.end() || iBest->second.IsObjInvalid())
        return nullptr;
    
    // Success
    return &iBest->second;
}
// Find a model by package name hash and short id
/// @note This is directly used by XPMP2-Remote client with a potentially limited short id string
Find a model by package name hash and short id
Find a model by package name hash and short id
CSLModel* CSLModelByPkgShortId (std::uint16_t _pkgHash,
                                const std::string& _shortId)
{
    mapCSLModelTy::iterator iBest = glob.mapCSLModels.end();
    for (mapCSLModelTy::iterator iter = glob.mapCSLModels.begin();
         iter != glob.mapCSLModels.end();
         ++iter)
    {
        if (std::strncmp(iter->second.GetShortId().c_str(), _shortId.c_str(), _shortId.length()) == 0) {
            if (iter->second.pkgHash == _pkgHash) {     
                iBest = iter;
                break;
            }
            else if (iBest == glob.mapCSLModels.end() &&
                     !iter->second.IsObjInvalid())
                iBest = iter;                           
        }
    }
    if (iBest == glob.mapCSLModels.end() || iBest->second.IsObjInvalid())
        return nullptr;
    return &iBest->second;
}
CSLModel * CSLModelByPkgShortId ( std :: uint16_t _pkgHash , const std :: string & _shortId ) { mapCSLModelTy :: iterator iBest = glob . mapCSLModels . end ( ) ; for ( mapCSLModelTy :: iterator iter = glob . mapCSLModels . begin ( ) ; iter != glob . mapCSLModels . end ( ) ; ++ iter ) { if ( std :: strncmp ( iter -> second . GetShortId ( ) . c_str ( ) , _shortId . c_str ( ) , _shortId . length ( ) ) == 0 ) { if ( iter -> second . pkgHash == _pkgHash ) { iBest = iter ; break ; } else if ( iBest == glob . mapCSLModels . end ( ) && ! iter -> second . IsObjInvalid ( ) ) iBest = iter ; } } if ( iBest == glob . mapCSLModels . end ( ) || iBest -> second . IsObjInvalid ( ) ) return nullptr ; return & iBest -> second ; }
Find a model by package name hash and short id
Find a model by package name hash and short id
// try finding the model by shortId, also verify pckage hash // short id matches...as far as known // perfect match! // remember the first model for which at least the short id matches // but keep on searching // not found, or invalid? // Success