#include <MappingRules.h>
Classes | |
struct | ToUpper |
Static Public Member Functions | |
static std::string | baseClassVersion () |
static std::string | baseIdForClass (const std::string &className) |
static std::string | classId (const std::string &className, const std::string &classVersion) |
static std::pair< bool, std::string > | classNameFromBaseId (const std::string &classId) |
static std::string | classVersionFromId (const std::string &classId) |
static std::string | classVersionPropertyNameInDictionary () |
static std::string | columnNameForId () |
static std::string | columnNameForNamedReference (const std::string &variableName, const std::string &scope) |
static std::string | columnNameForOID (const std::string &variableName, const std::string &scope, unsigned int index) |
static std::string | columnNameForPosition () |
static std::string | columnNameForRefColumn () |
static std::string | columnNameForRefId (const std::string &variableName, const std::string &scope) |
static std::string | columnNameForRefMetadata (const std::string &variableName, const std::string &scope) |
static std::string | columnNameForVariable (const std::string &variableName, const std::string &scope, bool forData=true) |
static std::string | defaultClassVersion (const std::string &className) |
static std::string | fkNameForIdentity (const std::string &tableName, int index=0) |
static std::string | formatName (const std::string &variableName, size_t maxLength) |
formatting for variable names to schema object names | |
static bool | isMappedToBlob (const std::string &mappingProperty) |
static std::string | mappingPropertyNameInDictionary () |
class related parameters | |
static std::string | newMappingVersionForContainer (const std::string &containerName, int iteration) |
mapping versions | |
static std::string | newMappingVersionForDependentClass (const std::string &containerName, const std::string &className, int iteration) |
static std::string | newNameForArraySchemaObject (const std::string &initialName, unsigned int index, size_t maxLength) |
static std::string | newNameForDepSchemaObject (const std::string &initialName, unsigned int index, size_t maxLength) |
static std::string | newNameForSchemaObject (const std::string &initialName, unsigned int index, size_t maxLength, char indexTrailer=0) |
functions for new schema object name generation | |
static std::string | scopedVariableForSchemaObjects (const std::string &variableName, const std::string &scope) |
static std::string | scopedVariableName (const std::string &variableName, const std::string &scope) |
variable name manipulation | |
static std::string | sequenceNameForContainer (const std::string &containerName) |
static std::string | sequenceNameForContainerId () |
sequence names | |
static std::string | sequenceNameForDependentClass (const std::string &containerName, const std::string &className) |
static std::string | sequenceNameForMapping () |
static std::string | tableNameForItem (const std::string &itemName) |
schema object naming | |
static std::string | variableNameForArrayColumn (const Reflex::Type &array) |
static std::string | variableNameForArrayColumn (unsigned int arrayIndex) |
static std::string | variableNameForArrayIndex (const std::string &arrayVariable, unsigned int index) |
static std::string | variableNameForContainerKey () |
static std::string | variableNameForContainerValue () |
Static Public Attributes | |
static const size_t | ClassNameLengthForSchema = 7 |
size parameters for table creation | |
static const size_t | MaxColumnNameLength = 30 |
static const size_t | MaxColumnsForInlineCArray = 13 |
static const size_t | MaxColumnsPerTable = 100 |
static const size_t | MaxTableNameLength = 20 |
Static Private Member Functions | |
static std::string | nameForSchema (const std::string &variableName) |
static std::string | nameFromTemplate (const std::string templateClassName, size_t maxLength) |
static std::string | newMappingVersion (const std::string &itemName, int iteration, char versionTrailer) |
static std::string | shortNameByUpperCase (const std::string &className, size_t maxLength) |
static std::string | shortScopedName (const std::string &scopedClassName, size_t maxLength) |
Definition at line 15 of file MappingRules.h.
std::string ora::MappingRules::baseClassVersion | ( | ) | [static] |
Definition at line 66 of file MappingRules.cc.
Referenced by ora::MappingDatabase::insertClassVersion().
{ static std::string classVersion("BASE"); return classVersion; }
std::string ora::MappingRules::baseIdForClass | ( | const std::string & | className | ) | [static] |
Definition at line 61 of file MappingRules.cc.
Referenced by ora::MappingDatabase::getBaseMappingForContainer(), and ora::MappingDatabase::insertClassVersion().
{ return className+"."+baseClassVersion(); }
std::string ora::MappingRules::classId | ( | const std::string & | className, |
const std::string & | classVersion | ||
) | [static] |
Definition at line 46 of file MappingRules.cc.
Referenced by ora::MappingDatabase::getMappingForContainer(), ora::MappingDatabase::insertClassVersion(), and ora::MappingDatabase::setMappingVersionForClass().
{ return className+".V"+classVersion; }
std::pair< bool, std::string > ora::MappingRules::classNameFromBaseId | ( | const std::string & | classId | ) | [static] |
Definition at line 72 of file MappingRules.cc.
References align_tpl::cut, and runTheMatrix::ret.
Referenced by ora::PoolMappingSchema::selectMappingVersion().
std::string ora::MappingRules::classVersionFromId | ( | const std::string & | classId | ) | [static] |
Definition at line 51 of file MappingRules.cc.
References runTheMatrix::ret.
Referenced by ora::PoolMappingSchema::selectMappingVersion(), and ora::PoolMappingSchema::setMappingVersion().
std::string ora::MappingRules::classVersionPropertyNameInDictionary | ( | ) | [static] |
Definition at line 91 of file MappingRules.cc.
Referenced by ora::MappingDatabase::versionOfClass().
{ static std::string s_propertyName("class_version"); return s_propertyName; }
std::string ora::MappingRules::columnNameForId | ( | ) | [static] |
Definition at line 377 of file MappingRules.cc.
Referenced by ora::MappingGenerator::createNewDependentMapping(), ora::MappingGenerator::createNewMapping(), ora::ArrayMapping::process(), and ora::CArrayMapping::process().
{ return std::string("ID"); }
std::string ora::MappingRules::columnNameForNamedReference | ( | const std::string & | variableName, |
const std::string & | scope | ||
) | [static] |
Definition at line 447 of file MappingRules.cc.
References runTheMatrix::ret.
Referenced by ora::NamedRefMapping::process().
{ std::stringstream ret; ret << "R" << columnNameForVariable( variableName, scope, false )<<"_NAME"; return ret.str(); }
std::string ora::MappingRules::columnNameForOID | ( | const std::string & | variableName, |
const std::string & | scope, | ||
unsigned int | index | ||
) | [static] |
Definition at line 437 of file MappingRules.cc.
References getHLTprescales::index, and runTheMatrix::ret.
Referenced by ora::OraReferenceMapping::process().
{ std::stringstream ret; ret << "R" << columnNameForVariable( variableName, scope, false )<<"_OID"<<index; return ret.str(); }
std::string ora::MappingRules::columnNameForPosition | ( | ) | [static] |
Definition at line 474 of file MappingRules.cc.
Referenced by ora::ArrayMapping::process(), and ora::CArrayMapping::process().
{ return std::string("POS"); }
std::string ora::MappingRules::columnNameForRefColumn | ( | ) | [static] |
Definition at line 383 of file MappingRules.cc.
Referenced by ora::MappingGenerator::createNewDependentMapping().
{ return std::string("REF_ID"); }
std::string ora::MappingRules::columnNameForRefId | ( | const std::string & | variableName, |
const std::string & | scope | ||
) | [static] |
Definition at line 465 of file MappingRules.cc.
References runTheMatrix::ret.
Referenced by ora::UniqueReferenceMapping::process().
{ std::stringstream ret; ret << "RID_" << columnNameForVariable( variableName, scope, false ); return ret.str(); }
std::string ora::MappingRules::columnNameForRefMetadata | ( | const std::string & | variableName, |
const std::string & | scope | ||
) | [static] |
Definition at line 456 of file MappingRules.cc.
References runTheMatrix::ret.
Referenced by ora::UniqueReferenceMapping::process().
{ std::stringstream ret; ret << "M" << columnNameForVariable( variableName, scope, false ); return ret.str(); }
std::string ora::MappingRules::columnNameForVariable | ( | const std::string & | variableName, |
const std::string & | scope, | ||
bool | forData = true |
||
) | [static] |
Definition at line 389 of file MappingRules.cc.
References runTheMatrix::ret.
Referenced by ora::processLeafElement().
{ std::ostringstream totalString; int scopeMaxSize = MaxColumnNameLength/4-1; int extraSize = MaxColumnNameLength-variableName.size()-2; if( extraSize>0 && extraSize>scopeMaxSize ) scopeMaxSize = extraSize; if( !scopeName.empty() ) { size_t scopeCut = scopeName.size(); if( scopeCut> (size_t)scopeMaxSize ) scopeCut = scopeMaxSize; totalString << scopeName.substr(0,scopeCut); totalString << "_"; } size_t varMaxSize = MaxColumnNameLength-totalString.str().size(); size_t fp = variableName.find('['); if( fp != std::string::npos ){ // process for c-arrays std::string arrayVar = variableName.substr(0,fp); std::string indexVar = variableName.substr(fp); for( size_t ind = 0; ind!=std::string::npos; ind=indexVar.find('[',ind+1 ) ){ indexVar = indexVar.replace(ind,1,"I"); } for( size_t ind = indexVar.find(']'); ind!=std::string::npos; ind=indexVar.find(']',ind+1 ) ){ indexVar = indexVar.replace(ind,1,"_"); } size_t arrayVarCut = 0; size_t varCut = variableName.size()+1; if( varCut>varMaxSize ) varCut = varMaxSize; if( varCut>(indexVar.size()+1) ) arrayVarCut = varCut-indexVar.size()-1; totalString << arrayVar.substr(0,arrayVarCut); totalString << "_" << indexVar; } else { size_t varCut = variableName.size(); if( varCut>varMaxSize ) varCut = varMaxSize; // other types totalString << variableName.substr(0,varCut); } std::stringstream ret; if(forData) ret << "D"; ret << nameForSchema(totalString.str()); //return formatForSchema(ret.str(),MaxColumnNameLength); return formatName(ret.str(),MaxColumnNameLength); }
std::string ora::MappingRules::defaultClassVersion | ( | const std::string & | className | ) | [static] |
Definition at line 83 of file MappingRules.cc.
Referenced by ora::MappingDatabase::versionOfClass().
{ std::string classVersion(className); classVersion.append("_default"); return classVersion; }
std::string ora::MappingRules::fkNameForIdentity | ( | const std::string & | tableName, |
int | index = 0 |
||
) | [static] |
Definition at line 480 of file MappingRules.cc.
References getHLTprescales::index, and runTheMatrix::ret.
Referenced by ora::MappingToSchema::createTable().
std::string ora::MappingRules::formatName | ( | const std::string & | variableName, |
size_t | maxLength | ||
) | [static] |
formatting for variable names to schema object names
Definition at line 488 of file MappingRules.cc.
Referenced by ora::MappingGenerator::createNewDependentMapping(), and ora::MappingGenerator::createNewMapping().
{ return nameFromTemplate( variableName, maxLength ); }
bool ora::MappingRules::isMappedToBlob | ( | const std::string & | mappingProperty | ) | [static] |
Definition at line 41 of file MappingRules.cc.
Referenced by ora::ObjectMapping::process(), and ora::processBaseClasses().
{ return (mappingProperty == "Blob" || mappingProperty == "blob" || mappingProperty == "BLOB" ); }
std::string ora::MappingRules::mappingPropertyNameInDictionary | ( | ) | [static] |
class related parameters
Definition at line 34 of file MappingRules.cc.
Referenced by ora::ObjectMapping::process(), and ora::processBaseClasses().
{ static std::string s_propertyName("mapping"); return s_propertyName; }
std::string ora::MappingRules::nameForSchema | ( | const std::string & | variableName | ) | [static, private] |
Definition at line 233 of file MappingRules.cc.
{ std::string varName( variableName ); //first turn className into uppercase MappingRules::ToUpper up(std::locale::classic()); std::transform(varName.begin(), varName.end(),varName.begin(),up); size_t cutPoint = varName.size(); if(cutPoint && varName[varName.size()-1] == '_' ) cutPoint -= 1; if(!cutPoint) return ""; size_t start = 0; if(varName.size() && varName[0]== '_' ) start = 1; return varName.substr(start,cutPoint); }
std::string ora::MappingRules::nameFromTemplate | ( | const std::string | templateClassName, |
size_t | maxLength | ||
) | [static, private] |
Definition at line 343 of file MappingRules.cc.
References prof2calltree::prefix.
{ if( !maxLength ) return ""; std::string newName(""); size_t ind0 = templateClassName.find('<',0); if( ind0 != std::string::npos ){ size_t ind1 = templateClassName.rfind('>'); std::string templArg = templateClassName.substr( ind0+1, ind1-ind0-1 ); std::string prefix = shortScopedName( templateClassName.substr( 0, ind0 ), maxLength ); size_t currSize = templArg.size()+prefix.size()+1; if( currSize > maxLength+1 ){ // a cut is required... size_t prefixL = maxLength/3; if( prefixL == 0 ) prefixL = 1; if( prefixL >1 ) prefixL -=1; prefix = shortScopedName( prefix, prefixL ); } size_t templMaxSize = maxLength-prefix.size()-1; templArg = nameFromTemplate( templArg, templMaxSize ); newName = prefix+"_"+ templArg; } else { newName = shortScopedName( templateClassName, maxLength ); } //checkString( newName, 3 ); return newName; }
std::string ora::MappingRules::newMappingVersion | ( | const std::string & | itemName, |
int | iteration, | ||
char | versionTrailer | ||
) | [static, private] |
Definition at line 99 of file MappingRules.cc.
References align_cfg::iteration.
std::string ora::MappingRules::newMappingVersionForContainer | ( | const std::string & | containerName, |
int | iteration | ||
) | [static] |
mapping versions
Definition at line 116 of file MappingRules.cc.
Referenced by ora::MappingDatabase::newMappingVersionForContainer().
{ return newMappingVersion( containerName, iteration, 'M' ); }
std::string ora::MappingRules::newMappingVersionForDependentClass | ( | const std::string & | containerName, |
const std::string & | className, | ||
int | iteration | ||
) | [static] |
Definition at line 122 of file MappingRules.cc.
References className().
Referenced by ora::MappingDatabase::newMappingVersionForDependentClass().
{ std::string contDependencyName = containerName+"_"+className; return newMappingVersion( contDependencyName, iteration, 'D' ); }
std::string ora::MappingRules::newNameForArraySchemaObject | ( | const std::string & | initialName, |
unsigned int | index, | ||
size_t | maxLength | ||
) | [static] |
Definition at line 225 of file MappingRules.cc.
Referenced by ora::ArrayMapping::process(), and ora::CArrayMapping::process().
{ return newNameForSchemaObject( initialName, index, maxL, 'A' ); }
std::string ora::MappingRules::newNameForDepSchemaObject | ( | const std::string & | initialName, |
unsigned int | index, | ||
size_t | maxLength | ||
) | [static] |
Definition at line 217 of file MappingRules.cc.
Referenced by ora::MappingGenerator::createNewDependentMapping().
{ return newNameForSchemaObject( initialName, index, maxLength, 'D' ); }
std::string ora::MappingRules::newNameForSchemaObject | ( | const std::string & | initialName, |
unsigned int | index, | ||
size_t | maxLength, | ||
char | indexTrailer = 0 |
||
) | [static] |
functions for new schema object name generation
Definition at line 197 of file MappingRules.cc.
References getHLTprescales::index.
Referenced by ora::OraReferenceMapping::process(), ora::UniqueReferenceMapping::process(), ora::NamedRefMapping::process(), and ora::processLeafElement().
{ unsigned int digitsForPostfix = 3; if(index<10) digitsForPostfix = 2; size_t newSize = initialName.size()+digitsForPostfix; if(newSize > maxLength) newSize = maxLength; unsigned int cutSize = newSize - digitsForPostfix; std::stringstream newStr(""); if( initialName[cutSize-1]=='_' ) cutSize -= 1; std::string cutString = initialName.substr(0, cutSize ); newStr << cutString << "_"; if( indexTrailer !=0 ) newStr<< indexTrailer; newStr<< index; //checkString( newStr.str(), 7 ); return newStr.str(); }
std::string ora::MappingRules::scopedVariableForSchemaObjects | ( | const std::string & | variableName, |
const std::string & | scope | ||
) | [static] |
Definition at line 172 of file MappingRules.cc.
Referenced by ora::processBaseClasses().
{ std::stringstream scopedName; if(!scope.empty()) scopedName << formatName(scope, ClassNameLengthForSchema) << "_"; scopedName << variableName; return scopedName.str(); }
std::string ora::MappingRules::scopedVariableName | ( | const std::string & | variableName, |
const std::string & | scope | ||
) | [static] |
variable name manipulation
Definition at line 131 of file MappingRules.cc.
Referenced by ora::ObjectStreamerBase::buildBaseDataMembers(), ora::ObjectStreamerBase::buildDataMembers(), and ora::processBaseClasses().
{ std::stringstream scopedName; if(!scope.empty()) scopedName << scope << "::"; scopedName << variableName; return scopedName.str(); }
std::string ora::MappingRules::sequenceNameForContainer | ( | const std::string & | containerName | ) | [static] |
Definition at line 14 of file MappingRules.cc.
References runTheMatrix::ret.
Referenced by ora::PoolDbCache::add(), ora::ContainerSchema::drop(), ora::DatabaseContainer::insertItem(), and ora::PoolDbCache::remove().
std::string ora::MappingRules::sequenceNameForContainerId | ( | ) | [static] |
sequence names
Definition at line 9 of file MappingRules.cc.
Referenced by ora::PoolDbCache::add(), ora::PoolDbCache::clear(), and ora::DatabaseSession::startTransaction().
{ static std::string s_sequenceName("CONTAINER_ID"); return s_sequenceName; }
std::string ora::MappingRules::sequenceNameForDependentClass | ( | const std::string & | containerName, |
const std::string & | className | ||
) | [static] |
Definition at line 20 of file MappingRules.cc.
References className(), and runTheMatrix::ret.
Referenced by ora::ContainerSchema::drop(), and ora::UniqueRefWriter::write().
std::string ora::MappingRules::sequenceNameForMapping | ( | ) | [static] |
Definition at line 28 of file MappingRules.cc.
Referenced by ora::PoolDbCache::clear().
{ static std::string s_mappingSequenceName("MAPPING_ELEMENT_ID"); return s_mappingSequenceName; }
std::string ora::MappingRules::shortNameByUpperCase | ( | const std::string & | className, |
size_t | maxLength | ||
) | [static, private] |
Definition at line 246 of file MappingRules.cc.
References align_tpl::cut, i, j, and max().
{ if( !maxL ) return ""; if( className.size() < maxL ) return className; std::vector< size_t> uppers; for( size_t i=0;i<className.size();i++) { if(::isupper(className[i]) || ::isdigit(className[i]) ) uppers.push_back(i); } std::stringstream shName; size_t usize = uppers.size(); if( usize < maxL ){ size_t start = 0; size_t cut = maxL-usize; if( usize && (cut > uppers[0]) ) cut = uppers[0]; shName << className.substr( start, cut ); size_t left = maxL-cut-usize; if( usize > 1) left = 0; size_t curs = 0; for( size_t i=0; i<usize;i++){ size_t st = uppers[i]; curs = st+left+1; shName << className.substr(st,left+1); left = 0; } size_t maxIndex = className.size(); if( shName.str().size()<maxL && curs < maxIndex ){ size_t more = maxL - shName.str().size(); size_t max = curs+more; if(max > className.size()) max = className.size(); for( size_t j=curs;j<max-1;j++ ){ shName << className[j]; } } //checkString( shName.str(), 0 ); } else { shName << className[0]; for(size_t i=0 ;i<maxL-1;i++) { if( uppers[i] != 0 ) shName << className[uppers[i]]; } //checkString( shName.str(), 1 ); } return shName.str(); }
std::string ora::MappingRules::shortScopedName | ( | const std::string & | scopedClassName, |
size_t | maxLength | ||
) | [static, private] |
Definition at line 292 of file MappingRules.cc.
References runTheMatrix::ret.
{ if( !maxLength ) return ""; std::string cn = scopedClassName; std::string sn(""); size_t ns = cn.rfind("::"); if( ns!= std::string::npos ){ cn = scopedClassName.substr( ns+2 ); sn = scopedClassName.substr( 0, ns ); } // ns = cn.find(" "); while( ns != std::string::npos ){ cn = cn.replace( ns, 1, "_"); ns = cn.find(" "); } // ns = sn.find("::"); if( ns == 0 ){ sn = sn.substr( 2 ); ns = sn.find("::"); } while( ns != std::string::npos ){ sn = sn.replace( ns, 2, "_"); ns = sn.find("::"); } // if( sn[sn.size()-1]=='_' ) sn = sn.substr(0,sn.size()-1); // ignore if namespace==std if( sn == "std" ) sn = ""; size_t currSize = sn.size()+cn.size()+1; if( currSize > maxLength+1 ){ // a cut is required... size_t maxScopeLen = maxLength/3; if( maxScopeLen ==0 ) maxScopeLen = 1; if( maxScopeLen > 1 ) maxScopeLen -= 1; if( sn.size() > maxScopeLen ){ sn = sn.substr( 0,maxScopeLen ); } size_t availableSize = maxLength-sn.size(); if( sn.size() ) availableSize -= 1; cn =shortNameByUpperCase( cn, availableSize ); } std::string ret = sn; if(!ret.empty()) ret += "_"; ret += cn; //checkString( ret, 2 ); return ret; }
std::string ora::MappingRules::tableNameForItem | ( | const std::string & | itemName | ) | [static] |
schema object naming
Definition at line 371 of file MappingRules.cc.
Referenced by ora::MappingGenerator::createNewMapping().
{ return "ORA_C_"+nameForSchema(formatName( itemName, MaxTableNameLength-5 )); }
std::string ora::MappingRules::variableNameForArrayColumn | ( | const Reflex::Type & | array | ) | [static] |
Definition at line 155 of file MappingRules.cc.
{ std::stringstream contentTypeName; contentTypeName << "A" << array.ArrayLength(); return contentTypeName.str(); }
std::string ora::MappingRules::variableNameForArrayColumn | ( | unsigned int | arrayIndex | ) | [static] |
Definition at line 148 of file MappingRules.cc.
Referenced by ora::CArrayMapping::process().
{ std::ostringstream arrayElementLabel; arrayElementLabel << "I" << arrayIndex; return arrayElementLabel.str(); }
std::string ora::MappingRules::variableNameForArrayIndex | ( | const std::string & | arrayVariable, |
unsigned int | index | ||
) | [static] |
Definition at line 140 of file MappingRules.cc.
Referenced by ora::InlineCArrayStreamerBase::buildDataElement(), and ora::CArrayMapping::process().
{ std::ostringstream arrayElementLabel; arrayElementLabel << arrayVariable << "[" << index << "]"; return arrayElementLabel.str(); }
std::string ora::MappingRules::variableNameForContainerKey | ( | ) | [static] |
Definition at line 166 of file MappingRules.cc.
Referenced by ora::ArrayMapping::process().
{ static std::string s_ck("CK"); return s_ck; }
std::string ora::MappingRules::variableNameForContainerValue | ( | ) | [static] |
Definition at line 161 of file MappingRules.cc.
Referenced by ora::ArrayMapping::process().
{ static std::string s_cv("CV"); return s_cv; }
const size_t ora::MappingRules::ClassNameLengthForSchema = 7 [static] |
size parameters for table creation
Definition at line 18 of file MappingRules.h.
Referenced by ora::MappingGenerator::createNewDependentMapping(), and ora::MappingGenerator::createNewMapping().
const size_t ora::MappingRules::MaxColumnNameLength = 30 [static] |
Definition at line 20 of file MappingRules.h.
Referenced by ora::OraReferenceMapping::process(), ora::UniqueReferenceMapping::process(), ora::NamedRefMapping::process(), and ora::processLeafElement().
const size_t ora::MappingRules::MaxColumnsForInlineCArray = 13 [static] |
Definition at line 22 of file MappingRules.h.
Referenced by ora::CArrayMapping::process().
const size_t ora::MappingRules::MaxColumnsPerTable = 100 [static] |
Definition at line 21 of file MappingRules.h.
Referenced by ora::MappingGenerator::createNewDependentMapping(), ora::MappingGenerator::createNewMapping(), and ora::CArrayMapping::process().
const size_t ora::MappingRules::MaxTableNameLength = 20 [static] |
Definition at line 19 of file MappingRules.h.
Referenced by ora::MappingGenerator::createNewDependentMapping(), ora::ArrayMapping::process(), and ora::CArrayMapping::process().