How to use the replication.share.yidl.src.yidl.cpp_target.CPPCompoundType function in replication

To help you get started, we’ve selected a few replication examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xtreemfs / babudb / replication / share / yidl / src / yidl / cpp_target.py View on Github external
def getDefaultValue( self ): return "false"
    def getDummyValue( self ): return "false"


class CPPBufferType(CBufferType, CPPType): pass


class CPPEnumeratedType(CEnumeratedType, CPPType):
    def getDefaultValue( self ):
        return self.getEnumerators()[0].getIdentifier()


class CPPExceptionType(CExceptionType, CPPType): pass
class CPPInclude(CInclude, CPPConstruct): pass
class CPPInterface(CInterface, CPPConstruct): pass
class CPPMapType(CMapType, CPPCompoundType): pass    


class CPPModule(CModule, CPPConstruct):
    def __repr__( self ):            
        return "namespace " + self.getName() + "\n{\n" + indent( CModule.__repr__( self ), "  " ) + "\n};\n"


class CPPNumericType(CNumericType, CPPType): pass
class CPPOperation(COperation, CPPConstruct): pass
class CPPOperationParameter(COperationParameter, CPPConstruct): pass


class CPPPointerType(CPointerType, CPPType):
    def getDeclarationTypeName( self ):
        if self.getName() == "ptr" or self.getName() == "any":
            return "void*"
github xtreemfs / babudb / replication / share / yidl / src / yidl / cpp_target.py View on Github external
else:
            if default_value is not None:
                default_value = str( default_value )
                in_constructor_declaration = "const char* %(identifier)s = %(default_value)s, %(identifier)s_len = strlen( %(default_value ) )" % locals()
            else:
                in_constructor_declaration = "const char* %(identifier)s, size_t %(identifier)s_len" % locals()
        return in_constructor_declaration
    def getInConstructorInitialValue( self, identifier, with_stl=True ): return with_stl and identifier or ( "%(identifier)s, %(identifier)s_len" % locals() )
    def getOutConstructorDeclaration( self, identifier, with_stl=True ): return "std::string& " + identifier
    def getReturnTypeName( self ): return "std::string"
    def getSetterDefinitions( self, identifier ): return ( """void set_%(identifier)s( const std::string& %(identifier)s ) { set_%(identifier)s( %(identifier)s.c_str(), %(identifier)s.size() ); }""" % locals(),
                                               """void set_%(identifier)s( const char* %(identifier)s, size_t %(identifier)s_len ) { this->%(identifier)s.assign( %(identifier)s, %(identifier)s_len ); }""" % locals() )
    def getTempValueTypeName( self ): return "std::string"


class CPPStructType(CStructType, CPPCompoundType):
    def getAccessors( self):
        if len( self.getMembersDefinedInThisClass() ) > 0:
            accessors = []
            for member in self.getMembersDefinedInThisClass():
                accessors.extend( member.getType().getSetterDefinitions( member.getIdentifier() ) )                
                accessors.append( member.getType().getGetterDefinition( member.getIdentifier() ) )
            return "\n\n  " + "\n  ".join( accessors )
        else:
            return ""

    # The _ take members parameters so the OperationRequestTypes can add parameters to the constructor alone
    def _getConstructorPrototype( self, with_stl ):
        name = self.getName()
        return "%(name)s( " % locals() + ", ".join( [member.getType().getInConstructorDeclaration( member.getIdentifier(), member.getDefaultValue(), with_stl=with_stl ) for member in self.getMembers()] ) + " )"            
            
    def _getConstructorInitializers( self, with_stl ):
github xtreemfs / babudb / replication / share / yidl / src / yidl / cpp_target.py View on Github external
class CPPNumericType(CNumericType, CPPType): pass
class CPPOperation(COperation, CPPConstruct): pass
class CPPOperationParameter(COperationParameter, CPPConstruct): pass


class CPPPointerType(CPointerType, CPPType):
    def getDeclarationTypeName( self ):
        if self.getName() == "ptr" or self.getName() == "any":
            return "void*"
        else:
            return self.getQualifiedName( "::" )    


class CPPReferenceType(CReferenceType, CPPType): pass    
class CPPSequenceType(CSequenceType, CPPCompoundType): pass
    
    
class CPPStringType(CStringType, CPPType):
    def getDeclarationTypeName( self ): return "std::string"
    def getDummyValue( self ): return "std::string()"
    def getGetterDefinition( self, identifier ): return "const std::string& get_%(identifier)s() const { return %(identifier)s; }" % locals()
    def getIncludes( self ): return CStringType.getIncludes( self ) + [CPPInclude( self.getScope(), "string", False )]
    def getInConstructorDeclaration( self, identifier, default_value=None, with_stl=True ): 
        if with_stl:
            in_constructor_declaration = "const std::string& " + identifier
            if default_value is not None: in_constructor_declaration += " = " + str( default_value )
        else:
            if default_value is not None:
                default_value = str( default_value )
                in_constructor_declaration = "const char* %(identifier)s = %(default_value)s, %(identifier)s_len = strlen( %(default_value ) )" % locals()
            else: