CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Static Public Member Functions | Static Public Attributes | Static Private Member Functions
ora::MappingRules Class Reference

#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 columnNameForBlobMetadata (const std::string &dataColumnName)
 
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 More...
 
static bool isLooseOnReading (const std::string &persistencyProperty)
 
static bool isLooseOnWriting (const std::string &persistencyProperty)
 
static bool isMappedToBlob (const std::string &mappingProperty)
 
static std::string mappingPropertyNameInDictionary ()
 class related parameters More...
 
static std::string newMappingVersionForContainer (const std::string &containerName, int iteration)
 mapping versions More...
 
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 More...
 
static std::string persistencyPropertyNameInDictionary ()
 
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 More...
 
static std::string sequenceNameForContainer (const std::string &containerName)
 
static std::string sequenceNameForContainerId ()
 sequence names More...
 
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 More...
 
static std::string variableNameForArrayColumn (unsigned int arrayIndex)
 
static std::string variableNameForArrayColumn (const Reflex::Type &array)
 
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 More...
 
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)
 

Detailed Description

Definition at line 15 of file MappingRules.h.

Member Function Documentation

std::string ora::MappingRules::baseClassVersion ( )
static

Definition at line 83 of file MappingRules.cc.

Referenced by ora::MappingDatabase::insertClassVersion().

84 {
85  static std::string classVersion("BASE");
86  return classVersion;
87 }
std::string ora::MappingRules::baseIdForClass ( const std::string &  className)
static

Definition at line 78 of file MappingRules.cc.

Referenced by ora::MappingDatabase::getBaseMappingForContainer(), and ora::MappingDatabase::insertClassVersion().

78  {
79  return className+"."+baseClassVersion();
80 }
static std::string baseClassVersion()
Definition: MappingRules.cc:83
std::string className(const T &t)
Definition: ClassName.h:30
std::string ora::MappingRules::classId ( const std::string &  className,
const std::string &  classVersion 
)
static

Definition at line 63 of file MappingRules.cc.

Referenced by ora::MappingDatabase::getMappingForContainer(), ora::MappingDatabase::insertClassVersion(), and ora::MappingDatabase::setMappingVersionForClass().

64  {
65  return className+".V"+classVersion;
66 }
std::string className(const T &t)
Definition: ClassName.h:30
std::pair< bool, std::string > ora::MappingRules::classNameFromBaseId ( const std::string &  classId)
static

Definition at line 89 of file MappingRules.cc.

References GOODCOLL_filter_cfg::cut, and run_regression::ret.

Referenced by ora::PoolMappingSchema::selectMappingVersion().

89  {
90  std::pair<bool,std::string> ret(false,"");
91  size_t cut = classId.find("."+baseClassVersion() );
92  if( cut != std::string::npos ){
93  ret.first = true;
94  ret.second = classId.substr(0,cut);
95  }
96  return ret;
97 }
static std::string baseClassVersion()
Definition: MappingRules.cc:83
static std::string classId(const std::string &className, const std::string &classVersion)
Definition: MappingRules.cc:63
std::string ora::MappingRules::classVersionFromId ( const std::string &  classId)
static

Definition at line 68 of file MappingRules.cc.

References run_regression::ret.

Referenced by ora::PoolMappingSchema::selectMappingVersion(), and ora::PoolMappingSchema::setMappingVersion().

68  {
69  std::string ret("");
70  size_t idx = classId.find('.');
71  if( idx != std::string::npos ){
72  ret = classId.substr( idx+2 );
73  }
74  return ret;
75 }
static std::string classId(const std::string &className, const std::string &classVersion)
Definition: MappingRules.cc:63
std::string ora::MappingRules::classVersionPropertyNameInDictionary ( )
static

Definition at line 108 of file MappingRules.cc.

Referenced by ora::MappingDatabase::versionOfClass().

109 {
110  static std::string s_propertyName("class_version");
111  return s_propertyName;
112 
113 }
std::string ora::MappingRules::columnNameForBlobMetadata ( const std::string &  dataColumnName)
static

Definition at line 510 of file MappingRules.cc.

References prof2calltree::prefix.

Referenced by ora::processLeafElement().

510  {
511  std::string prefix("M");
512  return prefix + dataColumnName.substr(1);
513 }
std::string ora::MappingRules::columnNameForId ( )
static
std::string ora::MappingRules::columnNameForNamedReference ( const std::string &  variableName,
const std::string &  scope 
)
static

Definition at line 477 of file MappingRules.cc.

References run_regression::ret.

Referenced by ora::NamedRefMapping::process().

479 {
480  std::stringstream ret;
481  ret << "R" << columnNameForVariable( variableName, scope, false )<<"_NAME";
482  return ret.str();
483 }
static std::string columnNameForVariable(const std::string &variableName, const std::string &scope, bool forData=true)
std::string ora::MappingRules::columnNameForOID ( const std::string &  variableName,
const std::string &  scope,
unsigned int  index 
)
static

Definition at line 467 of file MappingRules.cc.

References getHLTprescales::index, and run_regression::ret.

Referenced by ora::OraReferenceMapping::process().

470 {
471  std::stringstream ret;
472  ret << "R" << columnNameForVariable( variableName, scope, false )<<"_OID"<<index;
473  return ret.str();
474 }
static std::string columnNameForVariable(const std::string &variableName, const std::string &scope, bool forData=true)
std::string ora::MappingRules::columnNameForPosition ( )
static

Definition at line 504 of file MappingRules.cc.

Referenced by ora::ArrayMapping::process(), and ora::CArrayMapping::process().

505 {
506  return std::string("POS");
507 }
std::string ora::MappingRules::columnNameForRefColumn ( )
static

Definition at line 413 of file MappingRules.cc.

Referenced by ora::MappingGenerator::createNewDependentMapping().

414 {
415  return std::string("REF_ID");
416 }
std::string ora::MappingRules::columnNameForRefId ( const std::string &  variableName,
const std::string &  scope 
)
static

Definition at line 495 of file MappingRules.cc.

References run_regression::ret.

Referenced by ora::UniqueReferenceMapping::process().

497 {
498  std::stringstream ret;
499  ret << "RID_" << columnNameForVariable( variableName, scope, false );
500  return ret.str();
501 }
static std::string columnNameForVariable(const std::string &variableName, const std::string &scope, bool forData=true)
std::string ora::MappingRules::columnNameForRefMetadata ( const std::string &  variableName,
const std::string &  scope 
)
static

Definition at line 486 of file MappingRules.cc.

References run_regression::ret.

Referenced by ora::UniqueReferenceMapping::process().

488 {
489  std::stringstream ret;
490  ret << "M" << columnNameForVariable( variableName, scope, false );
491  return ret.str();
492 }
static std::string columnNameForVariable(const std::string &variableName, const std::string &scope, bool forData=true)
std::string ora::MappingRules::columnNameForVariable ( const std::string &  variableName,
const std::string &  scope,
bool  forData = true 
)
static

Definition at line 419 of file MappingRules.cc.

References run_regression::ret.

Referenced by ora::processLeafElement().

422 {
423  std::ostringstream totalString;
424  int scopeMaxSize = MaxColumnNameLength/4-1;
425  int extraSize = MaxColumnNameLength-variableName.size()-2;
426  if( extraSize>0 && extraSize>scopeMaxSize ) scopeMaxSize = extraSize;
427  if( !scopeName.empty() ) {
428  size_t scopeCut = scopeName.size();
429  if( scopeCut> (size_t)scopeMaxSize ) scopeCut = scopeMaxSize;
430  totalString << scopeName.substr(0,scopeCut);
431  totalString << "_";
432  }
433  size_t varMaxSize = MaxColumnNameLength-totalString.str().size();
434 
435  size_t fp = variableName.find('[');
436  if( fp != std::string::npos ){
437  // process for c-arrays
438  std::string arrayVar = variableName.substr(0,fp);
439  std::string indexVar = variableName.substr(fp);
440  for( size_t ind = 0; ind!=std::string::npos; ind=indexVar.find('[',ind+1 ) ){
441  indexVar = indexVar.replace(ind,1,"I");
442  }
443  for( size_t ind = indexVar.find(']'); ind!=std::string::npos; ind=indexVar.find(']',ind+1 ) ){
444  indexVar = indexVar.replace(ind,1,"_");
445  }
446  size_t arrayVarCut = 0;
447  size_t varCut = variableName.size()+1;
448  if( varCut>varMaxSize ) varCut = varMaxSize;
449  if( varCut>(indexVar.size()+1) ) arrayVarCut = varCut-indexVar.size()-1;
450  totalString << arrayVar.substr(0,arrayVarCut);
451  totalString << "_" << indexVar;
452  } else {
453  size_t varCut = variableName.size();
454  if( varCut>varMaxSize ) varCut = varMaxSize;
455  // other types
456  totalString << variableName.substr(0,varCut);
457  }
458 
459  std::stringstream ret;
460  if(forData) ret << "D";
461  ret << nameForSchema(totalString.str());
462  //return formatForSchema(ret.str(),MaxColumnNameLength);
463  return formatName(ret.str(),MaxColumnNameLength);
464 }
static std::string nameForSchema(const std::string &variableName)
static const size_t MaxColumnNameLength
Definition: MappingRules.h:20
static std::string formatName(const std::string &variableName, size_t maxLength)
formatting for variable names to schema object names
std::string ora::MappingRules::defaultClassVersion ( const std::string &  className)
static

Definition at line 100 of file MappingRules.cc.

Referenced by ora::MappingDatabase::versionOfClass().

101 {
102  std::string classVersion(className);
103  classVersion.append("_default");
104  return classVersion;
105 }
std::string className(const T &t)
Definition: ClassName.h:30
std::string ora::MappingRules::fkNameForIdentity ( const std::string &  tableName,
int  index = 0 
)
static

Definition at line 516 of file MappingRules.cc.

References getHLTprescales::index, and run_regression::ret.

Referenced by ora::MappingToSchema::createTable().

517 {
518  std::stringstream ret;
519  ret << tableName <<"_ID_FK";
520  if( index ) ret << "_"<<index;
521  return ret.str();
522 }
std::string ora::MappingRules::formatName ( const std::string &  variableName,
size_t  maxLength 
)
static

formatting for variable names to schema object names

Definition at line 524 of file MappingRules.cc.

Referenced by ora::MappingGenerator::createNewDependentMapping(), and ora::MappingGenerator::createNewMapping().

525  {
526  return nameFromTemplate( variableName, maxLength );
527 }
static std::string nameFromTemplate(const std::string &templateClassName, size_t maxLength)
bool ora::MappingRules::isLooseOnReading ( const std::string &  persistencyProperty)
static

Definition at line 53 of file MappingRules.cc.

Referenced by ora::isLoosePersistencyDataMember().

53  {
54  return (persistencyProperty == "loose_on_reading" || persistencyProperty == "LOOSE_ON_READING" );
55 }
bool ora::MappingRules::isLooseOnWriting ( const std::string &  persistencyProperty)
static

Definition at line 58 of file MappingRules.cc.

Referenced by ora::isLoosePersistencyDataMember(), and ora::isLoosePersistencyOnWriting().

58  {
59  return (persistencyProperty == "loose_on_writing" || persistencyProperty == "LOOSE_ON_WRITING" );
60 }
bool ora::MappingRules::isMappedToBlob ( const std::string &  mappingProperty)
static

Definition at line 42 of file MappingRules.cc.

Referenced by ora::ObjectMapping::process(), and ora::processBaseClasses().

42  {
43  return (mappingProperty == "Blob" || mappingProperty == "blob" || mappingProperty == "BLOB" );
44 }
std::string ora::MappingRules::mappingPropertyNameInDictionary ( )
static

class related parameters

Definition at line 35 of file MappingRules.cc.

Referenced by ora::ObjectMapping::process(), and ora::processBaseClasses().

36 {
37  static std::string s_propertyName("mapping");
38  return s_propertyName;
39 }
std::string ora::MappingRules::nameForSchema ( const std::string &  variableName)
staticprivate

Definition at line 250 of file MappingRules.cc.

References errorMatrix2Lands_multiChannel::start, and create_public_pileup_plots::transform.

250  {
251  std::string varName( variableName );
252  //first turn className into uppercase
253  MappingRules::ToUpper up(std::locale::classic());
254  std::transform(varName.begin(), varName.end(),varName.begin(),up);
255  size_t cutPoint = varName.size();
256  if(cutPoint && varName[varName.size()-1] == '_' ) cutPoint -= 1;
257  if(!cutPoint) return "";
258  size_t start = 0;
259  if(varName.size() && varName[0]== '_' ) start = 1;
260  return varName.substr(start,cutPoint);
261 }
std::string ora::MappingRules::nameFromTemplate ( const std::string &  templateClassName,
size_t  maxLength 
)
staticprivate

Definition at line 360 of file MappingRules.cc.

References i, and prof2calltree::prefix.

361  {
362  if( !maxLength ) return "";
363  std::string tempClassName(templateClassName);
364  size_t indComas = tempClassName.find(',',0);
365  std::vector<size_t> vComas;
366  while(indComas != std::string::npos) {
367  vComas.push_back(indComas);
368  indComas = tempClassName.find(',',indComas+1);
369  }
370  typedef std::vector<size_t>::const_iterator vSizeIter;
371  vSizeIter vBegin = vComas.begin();
372  vSizeIter vEnd = vComas.end();
373  for(vSizeIter i = vBegin; i != vEnd; ++i) {
374  tempClassName.replace(*i, 1, 1, '_');
375  }
376  std::string newName("");
377  size_t ind0 = tempClassName.find('<',0);
378  if( ind0 != std::string::npos ){
379  size_t ind1 = tempClassName.rfind('>');
380  std::string templArg = tempClassName.substr( ind0+1, ind1-ind0-1 );
381  std::string prefix = shortScopedName( tempClassName.substr( 0, ind0 ), maxLength );
382  size_t currSize = templArg.size()+prefix.size()+1;
383  if( currSize > maxLength+1 ){
384  // a cut is required...
385  size_t prefixL = maxLength/3;
386  if( prefixL == 0 ) prefixL = 1;
387  if( prefixL >1 ) prefixL -=1;
388  prefix = shortScopedName( prefix, prefixL );
389  }
390  size_t templMaxSize = maxLength-prefix.size()-1;
391  templArg = nameFromTemplate( templArg, templMaxSize );
392  newName = prefix+"_"+ templArg;
393  } else {
394  newName = shortScopedName( tempClassName, maxLength );
395  }
396  //checkString( newName, 3 );
397  return newName;
398 }
int i
Definition: DBlmapReader.cc:9
static std::string shortScopedName(const std::string &scopedClassName, size_t maxLength)
static std::string nameFromTemplate(const std::string &templateClassName, size_t maxLength)
std::string ora::MappingRules::newMappingVersion ( const std::string &  itemName,
int  iteration,
char  versionTrailer 
)
staticprivate

Definition at line 116 of file MappingRules.cc.

References align_cfg::iteration.

118  {
119  std::ostringstream os;
120  os << itemName;
121  os << "_" << versionTrailer;
122  if ( iteration > 0 ) {
123  if ( iteration < 10 ) os << "0";
124  if ( iteration < 100 ) os << "0";
125  os << iteration;
126  } else {
127  os << "000";
128  }
129  return os.str();
130 }
tuple iteration
Definition: align_cfg.py:5
std::string ora::MappingRules::newMappingVersionForContainer ( const std::string &  containerName,
int  iteration 
)
static

mapping versions

Definition at line 133 of file MappingRules.cc.

Referenced by ora::MappingDatabase::newMappingVersionForContainer().

134  {
135  return newMappingVersion( containerName, iteration, 'M' );
136 }
tuple iteration
Definition: align_cfg.py:5
static std::string newMappingVersion(const std::string &itemName, int iteration, char versionTrailer)
std::string ora::MappingRules::newMappingVersionForDependentClass ( const std::string &  containerName,
const std::string &  className,
int  iteration 
)
static

Definition at line 139 of file MappingRules.cc.

References className().

Referenced by ora::MappingDatabase::newMappingVersionForDependentClass().

142 {
143  std::string contDependencyName = containerName+"_"+className;
144  return newMappingVersion( contDependencyName, iteration, 'D' );
145 }
tuple iteration
Definition: align_cfg.py:5
static std::string newMappingVersion(const std::string &itemName, int iteration, char versionTrailer)
std::string className(const T &t)
Definition: ClassName.h:30
std::string ora::MappingRules::newNameForArraySchemaObject ( const std::string &  initialName,
unsigned int  index,
size_t  maxLength 
)
static

Definition at line 242 of file MappingRules.cc.

Referenced by ora::ArrayMapping::process(), and ora::CArrayMapping::process().

245 {
246  return newNameForSchemaObject( initialName, index, maxL, 'A' );
247 }
static std::string newNameForSchemaObject(const std::string &initialName, unsigned int index, size_t maxLength, char indexTrailer=0)
functions for new schema object name generation
std::string ora::MappingRules::newNameForDepSchemaObject ( const std::string &  initialName,
unsigned int  index,
size_t  maxLength 
)
static

Definition at line 234 of file MappingRules.cc.

Referenced by ora::MappingGenerator::createNewDependentMapping().

237 {
238  return newNameForSchemaObject( initialName, index, maxLength, 'D' );
239 }
static std::string newNameForSchemaObject(const std::string &initialName, unsigned int index, size_t maxLength, char indexTrailer=0)
functions for new schema object name generation
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 214 of file MappingRules.cc.

References getHLTprescales::index.

Referenced by ora::OraReferenceMapping::process(), ora::UniqueReferenceMapping::process(), ora::NamedRefMapping::process(), and ora::processLeafElement().

217  {
218  unsigned int digitsForPostfix = 3;
219  if(index<10) digitsForPostfix = 2;
220  size_t newSize = initialName.size()+digitsForPostfix;
221  if(newSize > maxLength) newSize = maxLength;
222  unsigned int cutSize = newSize - digitsForPostfix;
223  std::stringstream newStr("");
224  if( initialName[cutSize-1]=='_' ) cutSize -= 1;
225  std::string cutString = initialName.substr(0, cutSize );
226  newStr << cutString << "_";
227  if( indexTrailer !=0 ) newStr<< indexTrailer;
228  newStr<< index;
229  //checkString( newStr.str(), 7 );
230  return newStr.str();
231 }
std::string ora::MappingRules::persistencyPropertyNameInDictionary ( )
static

Definition at line 47 of file MappingRules.cc.

Referenced by ora::isLoosePersistencyDataMember(), and ora::isLoosePersistencyOnWriting().

47  {
48  static std::string s_propertyName("persistency");
49  return s_propertyName;
50 }
std::string ora::MappingRules::scopedVariableForSchemaObjects ( const std::string &  variableName,
const std::string &  scope 
)
static

Definition at line 189 of file MappingRules.cc.

Referenced by ora::processBaseClasses().

190  {
191  std::stringstream scopedName;
192  if(!scope.empty()) scopedName << formatName(scope, ClassNameLengthForSchema) << "_";
193  scopedName << variableName;
194  return scopedName.str();
195 }
static const size_t ClassNameLengthForSchema
size parameters for table creation
Definition: MappingRules.h:18
static std::string formatName(const std::string &variableName, size_t maxLength)
formatting for variable names to schema object names
std::string ora::MappingRules::scopedVariableName ( const std::string &  variableName,
const std::string &  scope 
)
static

variable name manipulation

Definition at line 148 of file MappingRules.cc.

Referenced by ora::ObjectStreamerBase::buildBaseDataMembers(), ora::ObjectStreamerBase::buildDataMembers(), and ora::processBaseClasses().

149  {
150  std::stringstream scopedName;
151  if(!scope.empty()) scopedName << scope << "::";
152  scopedName << variableName;
153  return scopedName.str();
154 }
std::string ora::MappingRules::sequenceNameForContainer ( const std::string &  containerName)
static
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().

9  {
10  static std::string s_sequenceName("CONTAINER_ID");
11  return s_sequenceName;
12 }
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 run_regression::ret.

Referenced by ora::ContainerSchema::create(), ora::ContainerSchema::drop(), ora::DatabaseUtilitySession::importContainerSchema(), and ora::UniqueRefWriter::write().

21  {
22  std::string ret("D_");
23  ret+=containerName;
24  ret+="_";
25  ret+=className;
26  return ret;
27 }
std::string className(const T &t)
Definition: ClassName.h:30
std::string ora::MappingRules::sequenceNameForMapping ( )
static

Definition at line 29 of file MappingRules.cc.

Referenced by ora::PoolDbCache::clear().

29  {
30  static std::string s_mappingSequenceName("MAPPING_ELEMENT_ID");
31  return s_mappingSequenceName;
32 }
std::string ora::MappingRules::shortNameByUpperCase ( const std::string &  className,
size_t  maxLength 
)
staticprivate

Definition at line 263 of file MappingRules.cc.

References GOODCOLL_filter_cfg::cut, i, j, max(), and errorMatrix2Lands_multiChannel::start.

264  {
265  if( !maxL ) return "";
266  if( className.size() < maxL ) return className;
267  std::vector< size_t> uppers;
268  for( size_t i=0;i<className.size();i++) {
269  if(::isupper(className[i]) || ::isdigit(className[i]) ) uppers.push_back(i);
270  }
271  std::stringstream shName;
272  size_t usize = uppers.size();
273  if( usize < maxL ){
274  size_t start = 0;
275  size_t cut = maxL-usize;
276  if( usize && (cut > uppers[0]) ) cut = uppers[0];
277  shName << className.substr( start, cut );
278  size_t left = maxL-cut-usize;
279  if( usize > 1) left = 0;
280  size_t curs = 0;
281  for( size_t i=0; i<usize;i++){
282  size_t st = uppers[i];
283  curs = st+left+1;
284  shName << className.substr(st,left+1);
285  left = 0;
286  }
287  size_t maxIndex = className.size();
288  if( shName.str().size()<maxL && curs < maxIndex ){
289  size_t more = maxL - shName.str().size();
290  size_t max = curs+more;
291  if(max > className.size()) max = className.size();
292  for( size_t j=curs;j<max-1;j++ ){
293  shName << className[j];
294  }
295  }
296 
297  //checkString( shName.str(), 0 );
298  } else {
299  shName << className[0];
300  for(size_t i=0 ;i<maxL-1;i++) {
301  if( uppers[i] != 0 ) shName << className[uppers[i]];
302  }
303  //checkString( shName.str(), 1 );
304  }
306  return shName.str();
307 }
int i
Definition: DBlmapReader.cc:9
const T & max(const T &a, const T &b)
int j
Definition: DBlmapReader.cc:9
std::string className(const T &t)
Definition: ClassName.h:30
std::string ora::MappingRules::shortScopedName ( const std::string &  scopedClassName,
size_t  maxLength 
)
staticprivate

Definition at line 309 of file MappingRules.cc.

References run_regression::ret.

310  {
311  if( !maxLength ) return "";
312  std::string cn = scopedClassName;
313  std::string sn("");
314  size_t ns = cn.rfind("::");
315  if( ns!= std::string::npos ){
316  cn = scopedClassName.substr( ns+2 );
317  sn = scopedClassName.substr( 0, ns );
318  }
319  //
320  ns = cn.find(" ");
321  while( ns != std::string::npos ){
322  cn = cn.replace( ns, 1, "_");
323  ns = cn.find(" ");
324  }
325  //
326  ns = sn.find("::");
327  if( ns == 0 ){
328  sn = sn.substr( 2 );
329  ns = sn.find("::");
330  }
331  while( ns != std::string::npos ){
332  sn = sn.replace( ns, 2, "_");
333  ns = sn.find("::");
334  }
335  //
336  if( sn[sn.size()-1]=='_' ) sn = sn.substr(0,sn.size()-1);
337  // ignore if namespace==std
338  if( sn == "std" ) sn = "";
339 
340  size_t currSize = sn.size()+cn.size()+1;
341  if( currSize > maxLength+1 ){
342  // a cut is required...
343  size_t maxScopeLen = maxLength/3;
344  if( maxScopeLen ==0 ) maxScopeLen = 1;
345  if( maxScopeLen > 1 ) maxScopeLen -= 1;
346  if( sn.size() > maxScopeLen ){
347  sn = sn.substr( 0,maxScopeLen );
348  }
349  size_t availableSize = maxLength-sn.size();
350  if( sn.size() ) availableSize -= 1;
351  cn =shortNameByUpperCase( cn, availableSize );
352  }
353  std::string ret = sn;
354  if(!ret.empty()) ret += "_";
355  ret += cn;
356  //checkString( ret, 2 );
357  return ret;
358 }
static std::string shortNameByUpperCase(const std::string &className, size_t maxLength)
std::string ora::MappingRules::tableNameForItem ( const std::string &  itemName)
static

schema object naming

Definition at line 401 of file MappingRules.cc.

Referenced by ora::MappingGenerator::createNewMapping().

402 {
403  return "ORA_C_"+nameForSchema(formatName( itemName, MaxTableNameLength-5 ));
404 }
static std::string nameForSchema(const std::string &variableName)
static const size_t MaxTableNameLength
Definition: MappingRules.h:19
static std::string formatName(const std::string &variableName, size_t maxLength)
formatting for variable names to schema object names
std::string ora::MappingRules::variableNameForArrayColumn ( unsigned int  arrayIndex)
static

Definition at line 165 of file MappingRules.cc.

Referenced by ora::CArrayMapping::process().

165  {
166  std::ostringstream arrayElementLabel;
167  arrayElementLabel << "I" << arrayIndex;
168  return arrayElementLabel.str();
169 }
std::string ora::MappingRules::variableNameForArrayColumn ( const Reflex::Type &  array)
static

Definition at line 172 of file MappingRules.cc.

172  {
173  std::stringstream contentTypeName;
174  contentTypeName << "A" << array.ArrayLength();
175  return contentTypeName.str();
176 }
std::string ora::MappingRules::variableNameForArrayIndex ( const std::string &  arrayVariable,
unsigned int  index 
)
static

Definition at line 157 of file MappingRules.cc.

Referenced by ora::InlineCArrayStreamerBase::buildDataElement(), and ora::CArrayMapping::process().

158  {
159  std::ostringstream arrayElementLabel;
160  arrayElementLabel << arrayVariable << "[" << index << "]";
161  return arrayElementLabel.str();
162 }
std::string ora::MappingRules::variableNameForContainerKey ( )
static

Definition at line 183 of file MappingRules.cc.

Referenced by ora::ArrayMapping::process().

183  {
184  static std::string s_ck("CK");
185  return s_ck;
186 }
std::string ora::MappingRules::variableNameForContainerValue ( )
static

Definition at line 178 of file MappingRules.cc.

Referenced by ora::ArrayMapping::process().

178  {
179  static std::string s_cv("CV");
180  return s_cv;
181 }

Member Data Documentation

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
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
const size_t ora::MappingRules::MaxTableNameLength = 20
static