Go to the documentation of this file.00001 #ifndef INCLUDE_ORA_MAPPINGRULES_H
00002 #define INCLUDE_ORA_MAPPINGRULES_H
00003
00004
00005 #include <string>
00006 #include <locale>
00007 #include <algorithm>
00008
00009 namespace Reflex{
00010 class Type;
00011 }
00012
00013 namespace ora {
00014
00015 class MappingRules {
00016 public:
00018 static const size_t ClassNameLengthForSchema = 7;
00019 static const size_t MaxTableNameLength = 20;
00020 static const size_t MaxColumnNameLength = 30;
00021 static const size_t MaxColumnsPerTable = 100;
00022 static const size_t MaxColumnsForInlineCArray = 13;
00023
00024 public:
00026 static std::string sequenceNameForContainerId();
00027 static std::string sequenceNameForContainer( const std::string& containerName );
00028 static std::string sequenceNameForDependentClass( const std::string& containerName, const std::string& className );
00029 static std::string sequenceNameForMapping();
00030
00032 static std::string newMappingVersionForContainer( const std::string& containerName, int iteration );
00033 static std::string newMappingVersionForDependentClass( const std::string& containerName, const std::string& className, int iteration );
00034
00036 static std::string mappingPropertyNameInDictionary();
00037 static bool isMappedToBlob(const std::string& mappingProperty);
00038 static std::string classId( const std::string& className, const std::string& classVersion );
00039 static std::string classVersionFromId( const std::string& classId );
00040 static std::string baseIdForClass( const std::string& className );
00041 static std::string baseClassVersion();
00042 static std::pair<bool,std::string> classNameFromBaseId( const std::string& classId );
00043 static std::string defaultClassVersion(const std::string& className);
00044 static std::string classVersionPropertyNameInDictionary();
00045
00047 static std::string scopedVariableName( const std::string& variableName, const std::string& scope );
00048 static std::string variableNameForArrayIndex( const std::string& arrayVariable, unsigned int index );
00049 static std::string variableNameForArrayColumn( unsigned int arrayIndex );
00050 static std::string variableNameForArrayColumn( const Reflex::Type& array );
00051 static std::string variableNameForContainerValue();
00052 static std::string variableNameForContainerKey();
00053 static std::string scopedVariableForSchemaObjects( const std::string& variableName, const std::string& scope );
00054
00056 static std::string newNameForSchemaObject( const std::string& initialName, unsigned int index, size_t maxLength, char indexTrailer=0 );
00057 static std::string newNameForDepSchemaObject( const std::string& initialName, unsigned int index, size_t maxLength);
00058 static std::string newNameForArraySchemaObject( const std::string& initialName, unsigned int index, size_t maxLength);
00059
00061 static std::string tableNameForItem( const std::string& itemName );
00062 static std::string columnNameForId();
00063 static std::string columnNameForRefColumn();
00064 static std::string columnNameForVariable( const std::string& variableName, const std::string& scope, bool forData=true );
00065 static std::string columnNameForOID( const std::string& variableName, const std::string& scope, unsigned int index );
00066 static std::string columnNameForRefMetadata( const std::string& variableName, const std::string& scope );
00067 static std::string columnNameForRefId( const std::string& variableName, const std::string& scope );
00068 static std::string columnNameForPosition();
00069 static std::string columnNameForNamedReference( const std::string& variableName, const std::string& scope );
00070 static std::string fkNameForIdentity( const std::string& tableName, int index=0 );
00071
00073 static std::string formatName( const std::string& variableName, size_t maxLength );
00074
00075 private:
00076
00077 struct ToUpper {
00078 ToUpper(const std::locale& l):loc(l) {}
00079 char operator() (char c) const { return std::toupper(c,loc); }
00080 std::locale const& loc;
00081 };
00082 static std::string nameForSchema( const std::string& variableName );
00083 static std::string shortNameByUpperCase( const std::string& className, size_t maxLength );
00084 static std::string shortScopedName( const std::string& scopedClassName, size_t maxLength );
00085 static std::string nameFromTemplate( const std::string templateClassName, size_t maxLength );
00086
00087 static std::string newMappingVersion( const std::string& itemName, int iteration, char versionTrailer );
00088
00089
00094
00096
00102
00109
00116
00118
00123 };
00124 }
00125
00126 #endif
00127