11 static const std::string s_sequenceName(
"CONTAINER_ID");
12 return s_sequenceName;
17 return ret+containerName;
31 static const std::string s_mappingSequenceName(
"MAPPING_ELEMENT_ID");
32 return s_mappingSequenceName;
39 return s_propertyName;
44 return (mappingProperty ==
"Blob" || mappingProperty ==
"blob" || mappingProperty ==
"BLOB" );
49 static const std::string s_propertyName(
"persistency");
50 return s_propertyName;
55 return (persistencyProperty ==
"loose_on_reading" || persistencyProperty ==
"LOOSE_ON_READING" );
60 return (persistencyProperty ==
"loose_on_writing" || persistencyProperty ==
"LOOSE_ON_WRITING" );
66 return className+
".V"+classVersion;
71 size_t idx = classId.find(
'.');
72 if( idx != std::string::npos ){
73 ret = classId.substr( idx+2 );
80 return className+
"."+baseClassVersion();
91 std::pair<bool,std::string>
ret(
false,
"");
92 size_t cut = classId.find(
"."+baseClassVersion() );
93 if( cut != std::string::npos ){
95 ret.second = classId.substr(0,cut);
104 classVersion.append(
"_default");
111 static const std::string s_propertyName(
"class_version");
112 return s_propertyName;
119 char versionTrailer ){
120 std::ostringstream os;
122 os <<
"_" << versionTrailer;
123 if ( iteration > 0 ) {
124 if ( iteration < 10 ) os <<
"0";
125 if ( iteration < 100 ) os <<
"0";
136 return newMappingVersion( containerName, iteration,
'M' );
145 return newMappingVersion( contDependencyName, iteration,
'D' );
151 std::stringstream scopedName;
152 if(!scope.empty()) scopedName << scope <<
"::";
153 scopedName << variableName;
154 return scopedName.str();
159 unsigned int index ){
160 std::ostringstream arrayElementLabel;
161 arrayElementLabel << arrayVariable <<
"[" << index <<
"]";
162 return arrayElementLabel.str();
167 std::ostringstream arrayElementLabel;
168 arrayElementLabel <<
"I" << arrayIndex;
169 return arrayElementLabel.str();
174 std::stringstream contentTypeName;
176 contentTypeName <<
"A" << arraySize;
177 return contentTypeName.str();
193 std::stringstream scopedName;
194 if(!scope.empty()) scopedName << formatName(scope, ClassNameLengthForSchema) <<
"_";
195 scopedName << variableName;
196 return scopedName.str();
202 static const std::string validChars(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-0123456789");
204 for(
size_t i=0;
i<s.size();
i++){
206 std::stringstream mess;
207 mess <<
" code="<<code<<
" in string ["<<s<<
"] found a wrong char=["<<s[
i]<<
"].";
220 unsigned int digitsForPostfix = 3;
221 if(index<10) digitsForPostfix = 2;
222 size_t newSize = initialName.size()+digitsForPostfix;
223 if(newSize > maxLength) newSize = maxLength;
224 unsigned int cutSize = newSize - digitsForPostfix;
225 std::stringstream newStr(
"");
226 if( initialName[cutSize-1]==
'_' ) cutSize -= 1;
227 std::string cutString = initialName.substr(0, cutSize );
228 newStr << cutString <<
"_";
229 if( indexTrailer !=0 ) newStr<< indexTrailer;
240 return newNameForSchemaObject( initialName, index, maxLength,
'D' );
248 return newNameForSchemaObject( initialName, index, maxL,
'A' );
257 size_t cutPoint = varName.size();
258 if(cutPoint && varName[varName.size()-1] ==
'_' ) cutPoint -= 1;
259 if(!cutPoint)
return "";
261 if(varName.size() && varName[0]==
'_' ) start = 1;
262 return varName.substr(start,cutPoint);
267 if( !maxL )
return "";
268 if( className.size() < maxL )
return className;
269 std::vector< size_t> uppers;
270 for(
size_t i=0;
i<className.size();
i++) {
271 if(::isupper(className[
i]) || ::isdigit(className[i]) ) uppers.push_back(i);
273 std::stringstream shName;
274 size_t usize = uppers.size();
277 size_t cut = maxL-usize;
278 if( usize && (cut > uppers[0]) ) cut = uppers[0];
279 shName << className.substr( start, cut );
280 size_t left = maxL-cut-usize;
281 if( usize > 1) left = 0;
283 for(
size_t i=0;
i<usize;
i++){
284 size_t st = uppers[
i];
286 shName << className.substr(st,left+1);
289 size_t maxIndex = className.size();
290 if( shName.str().size()<maxL && curs < maxIndex ){
291 size_t more = maxL - shName.str().size();
292 size_t max = curs+more;
293 if(max > className.size()) max = className.size();
294 for(
size_t j=curs;
j<max-1;
j++ ){
295 shName << className[
j];
301 shName << className[0];
302 for(
size_t i=0 ;
i<maxL-1;
i++) {
303 if( uppers[
i] != 0 ) shName << className[uppers[
i]];
313 if( !maxLength )
return "";
316 size_t ns = cn.rfind(
"::");
317 if( ns!= std::string::npos ){
318 cn = scopedClassName.substr( ns+2 );
319 sn = scopedClassName.substr( 0, ns );
323 while( ns != std::string::npos ){
324 cn = cn.replace( ns, 1,
"_");
333 while( ns != std::string::npos ){
334 sn = sn.replace( ns, 2,
"_");
338 if( sn[sn.size()-1]==
'_' ) sn = sn.substr(0,sn.size()-1);
340 if( sn ==
"std" ) sn =
"";
342 size_t currSize = sn.size()+cn.size()+1;
343 if( currSize > maxLength+1 ){
345 size_t maxScopeLen = maxLength/3;
346 if( maxScopeLen ==0 ) maxScopeLen = 1;
347 if( maxScopeLen > 1 ) maxScopeLen -= 1;
348 if( sn.size() > maxScopeLen ){
349 sn = sn.substr( 0,maxScopeLen );
351 size_t availableSize = maxLength-sn.size();
352 if( sn.size() ) availableSize -= 1;
353 cn =shortNameByUpperCase( cn, availableSize );
356 if(!ret.empty()) ret +=
"_";
364 if( !maxLength )
return "";
366 size_t indComas = tempClassName.find(
',',0);
367 std::vector<size_t> vComas;
368 while(indComas != std::string::npos) {
369 vComas.push_back(indComas);
370 indComas = tempClassName.find(
',',indComas+1);
372 typedef std::vector<size_t>::const_iterator vSizeIter;
373 vSizeIter vBegin = vComas.begin();
374 vSizeIter vEnd = vComas.end();
375 for(vSizeIter
i = vBegin;
i != vEnd; ++
i) {
376 tempClassName.replace(*
i, 1, 1,
'_');
379 size_t ind0 = tempClassName.find(
'<',0);
380 if( ind0 != std::string::npos ){
381 size_t ind1 = tempClassName.rfind(
'>');
382 std::string templArg = tempClassName.substr( ind0+1, ind1-ind0-1 );
383 std::string prefix = shortScopedName( tempClassName.substr( 0, ind0 ), maxLength );
384 size_t currSize = templArg.size()+prefix.size()+1;
385 if( currSize > maxLength+1 ){
387 size_t prefixL = maxLength/3;
388 if( prefixL == 0 ) prefixL = 1;
389 if( prefixL >1 ) prefixL -=1;
390 prefix = shortScopedName( prefix, prefixL );
392 size_t templMaxSize = maxLength-prefix.size()-1;
393 templArg = nameFromTemplate( templArg, templMaxSize );
394 newName = prefix+
"_"+ templArg;
396 newName = shortScopedName( tempClassName, maxLength );
405 return "ORA_C_"+nameForSchema(formatName( itemName, MaxTableNameLength-5 ));
425 std::ostringstream totalString;
426 int scopeMaxSize = MaxColumnNameLength/4-1;
427 int extraSize = MaxColumnNameLength-variableName.size()-2;
428 if( extraSize>0 && extraSize>scopeMaxSize ) scopeMaxSize = extraSize;
429 if( !scopeName.empty() ) {
430 size_t scopeCut = scopeName.size();
431 if( scopeCut> (
size_t)scopeMaxSize ) scopeCut = scopeMaxSize;
432 totalString << scopeName.substr(0,scopeCut);
435 size_t varMaxSize = MaxColumnNameLength-totalString.str().size();
437 size_t fp = variableName.find(
'[');
438 if( fp != std::string::npos ){
442 for(
size_t ind = 0; ind!=std::string::npos; ind=indexVar.find(
'[',ind+1 ) ){
443 indexVar = indexVar.replace(ind,1,
"I");
445 for(
size_t ind = indexVar.find(
']'); ind!=std::string::npos; ind=indexVar.find(
']',ind+1 ) ){
446 indexVar = indexVar.replace(ind,1,
"_");
448 size_t arrayVarCut = 0;
449 size_t varCut = variableName.size()+1;
450 if( varCut>varMaxSize ) varCut = varMaxSize;
451 if( varCut>(indexVar.size()+1) ) arrayVarCut = varCut-indexVar.size()-1;
452 totalString << arrayVar.substr(0,arrayVarCut);
453 totalString <<
"_" << indexVar;
455 size_t varCut = variableName.size();
456 if( varCut>varMaxSize ) varCut = varMaxSize;
458 totalString << variableName.substr(0,varCut);
461 std::stringstream
ret;
462 if(forData) ret <<
"D";
463 ret << nameForSchema(totalString.str());
465 return formatName(ret.str(),MaxColumnNameLength);
473 std::stringstream
ret;
474 ret <<
"R" << columnNameForVariable( variableName, scope,
false )<<
"_OID"<<
index;
482 std::stringstream
ret;
483 ret <<
"R" << columnNameForVariable( variableName, scope,
false )<<
"_NAME";
491 std::stringstream
ret;
492 ret <<
"M" << columnNameForVariable( variableName, scope,
false );
500 std::stringstream
ret;
501 ret <<
"RID_" << columnNameForVariable( variableName, scope,
false );
514 return prefix + dataColumnName.substr(1);
520 std::stringstream
ret;
521 ret << tableName <<
"_ID_FK";
522 if( index ) ret <<
"_"<<
index;
528 return nameFromTemplate( variableName, maxLength );
tuple start
Check for commandline option errors.
static std::string columnNameForRefId(const std::string &variableName, const std::string &scope)
static std::string variableNameForArrayIndex(const std::string &arrayVariable, unsigned int index)
static std::string scopedVariableName(const std::string &variableName, const std::string &scope)
variable name manipulation
static std::string newMappingVersionForContainer(const std::string &containerName, int iteration)
mapping versions
static std::string variableNameForContainerKey()
static std::string variableNameForArrayColumn(unsigned int arrayIndex)
static std::string variableNameForContainerValue()
static std::string persistencyPropertyNameInDictionary()
static std::string newNameForDepSchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static std::string baseIdForClass(const std::string &className)
static std::string scopedVariableForSchemaObjects(const std::string &variableName, const std::string &scope)
static std::string shortScopedName(const std::string &scopedClassName, size_t maxLength)
static std::string columnNameForRefColumn()
static std::string columnNameForVariable(const std::string &variableName, const std::string &scope, bool forData=true)
static std::string mappingPropertyNameInDictionary()
class related parameters
static std::string columnNameForPosition()
static std::string shortNameByUpperCase(const std::string &className, size_t maxLength)
static std::string sequenceNameForMapping()
static std::string defaultClassVersion(const std::string &className)
static std::string newMappingVersion(const std::string &itemName, int iteration, char versionTrailer)
static std::string columnNameForOID(const std::string &variableName, const std::string &scope, unsigned int index)
static bool isLooseOnReading(const std::string &persistencyProperty)
static const std::string validChars("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-0123456789")
static std::string columnNameForBlobMetadata(const std::string &dataColumnName)
static std::string newNameForArraySchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static bool isMappedToBlob(const std::string &mappingProperty)
static std::string columnNameForId()
static std::string classVersionFromId(const std::string &classId)
static std::pair< bool, std::string > classNameFromBaseId(const std::string &classId)
void checkString(const std::string &s, int code, bool thro=true)
static bool isLooseOnWriting(const std::string &persistencyProperty)
static std::string columnNameForRefMetadata(const std::string &variableName, const std::string &scope)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
size_t arrayLength(const edm::TypeWithDict &typ)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
static std::string nameFromTemplate(const std::string &templateClassName, size_t maxLength)
static std::string baseClassVersion()
static std::string columnNameForNamedReference(const std::string &variableName, const std::string &scope)
static std::string nameForSchema(const std::string &variableName)
static std::string classId(const std::string &className, const std::string &classVersion)
static std::string sequenceNameForContainer(const std::string &containerName)
static std::string tableNameForItem(const std::string &itemName)
schema object naming
static std::string sequenceNameForContainerId()
sequence names
static std::string newMappingVersionForDependentClass(const std::string &containerName, const std::string &className, int iteration)
static std::string sequenceNameForDependentClass(const std::string &containerName, const std::string &className)
static std::string classVersionPropertyNameInDictionary()
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 formatName(const std::string &variableName, size_t maxLength)
formatting for variable names to schema object names
static std::string fkNameForIdentity(const std::string &tableName, int index=0)
std::string className(const T &t)