Public Member Functions | Public Attributes | Private Attributes

rm_String Class Reference
[Resource Manager Database Library]

#include <rmdb.h>

List of all members.

Public Member Functions

 rm_String ()
 rm_String (const rm_String &a_rmstr)
 rm_String (Int32_t a_lenght)
virtual ~rm_String ()
rm_Stringoperator= (const rm_String &a_rmString)
rm_Stringoperator= (const string &a_string)
rm_Stringoperator= (const char *a_cString)

Public Attributes

char * cvalue_p
 log_CLASSID_m

Private Attributes

UInt32_t m_maxLen

Detailed Description

Definition at line 83 of file rmdb.h.


Constructor & Destructor Documentation

rm_String::rm_String (  ) 

Definition at line 48 of file rmstring.cpp.

References ie_ARGUMENT_MISSING, and ivd_Error.

    :   m_maxLen(0),
        cvalue_p(NULL) {

    throw ivd_Error(ie_ARGUMENT_MISSING,
        "Argument (int - string length) for rm_String Constructor is mandatory", true);
}

rm_String::rm_String ( const rm_String a_rmstr  ) 

Definition at line 65 of file rmstring.cpp.

References cvalue_p, and m_maxLen.

    : string(""),
      m_maxLen(a_rmstr.m_maxLen),
      cvalue_p(NULL)  {

    // Prepare memory for char value
    cvalue_p = new char[m_maxLen + 1];
    cvalue_p[0] = '\0';

    // rm_String <-- char[] operator will be called
    (*this) = a_rmstr.cvalue_p;
}

rm_String::rm_String ( Int32_t  a_lenght  ) 

Definition at line 56 of file rmstring.cpp.

References cvalue_p, and m_maxLen.

    : m_maxLen(a_length),
      cvalue_p(NULL)    {

    // Prepare memory for char value
    cvalue_p = new char[m_maxLen + 1];
    cvalue_p[0] = '\0'; 
}

rm_String::~rm_String (  )  [virtual]

Definition at line 78 of file rmstring.cpp.

References cvalue_p, ie_DATA_CORRUPTION, and NULL.

                      {
    // cleanup memory
    if (cvalue_p != NULL) {
        delete [] cvalue_p;
        cvalue_p = NULL;
    } else throw ivd_InternalError(
        ie_DATA_CORRUPTION, "rm_String corrupt. pointer cvalue_p == NULL", true); 
}


Member Function Documentation

rm_String & rm_String::operator= ( const rm_String a_rmString  ) 

Definition at line 87 of file rmstring.cpp.

                                                              {

    //
    // this_string is a pointer to this, but is a of a string type.
    // dynamic_cast is used, because it is intended for conversion
    // from derived class to a base class.
    //
    //const string *rmAsString = dynamic_cast<string*>((rm_String*)&a_rmString);
    const string *rmAsString = dynamic_cast<const string*>(&a_rmString);
    (*this) = string::operator=(*rmAsString);

    return (*this);
}

rm_String & rm_String::operator= ( const char *  a_cString  ) 

Definition at line 133 of file rmstring.cpp.

References cmn_Num2Str(), cvalue_p, ie_DATA_CORRUPTION, ie_STRING_TOO_LONG, ivd_Error, m_maxLen, and NULL.

                                                    {

    if (cvalue_p == NULL) {
        throw ivd_InternalError(
            ie_DATA_CORRUPTION, "rm_String corrupt. pointer cvalue_p == NULL", true);
    }
    if (strlen(a_cString) > m_maxLen) {
        throw ivd_Error(ie_STRING_TOO_LONG,
            cmn_Num2Str(strlen(a_cString)) + string(">") +
            cmn_Num2Str(m_maxLen), true);
    }
    
    unsigned int strLength = strlen(a_cString);
    if (strLength > m_maxLen) {
        strLength = m_maxLen;
    }
    strncpy( cvalue_p, a_cString, strLength);
    cvalue_p[strLength] = '\0';

    //
    // this_string is a pointer to this, but is a of a string type.
    // dynamic_cast is used, because it is intended for conversion
    // from derived class to a base class.
    //
    
    string *this_string = dynamic_cast<string*>(this);

    // string <-- char[] operator will be called
    *this_string = cvalue_p;

    return *this;
}

Here is the call graph for this function:

rm_String & rm_String::operator= ( const string &  a_string  ) 

Definition at line 101 of file rmstring.cpp.

References cmn_Num2Str(), cvalue_p, ie_DATA_CORRUPTION, ie_STRING_TOO_LONG, ivd_Error, m_maxLen, and NULL.

                                                     {

    if (cvalue_p == NULL) {
        throw ivd_InternalError(
            ie_DATA_CORRUPTION, "rm_String corrupt. pointer cvalue_p == NULL", true);
    }
    
    if (a_string.length() > m_maxLen) {
        throw ivd_Error(ie_STRING_TOO_LONG,
            cmn_Num2Str(a_string.length()) + string(">") +
            cmn_Num2Str(m_maxLen), true);
    }

    string trimmed = a_string.substr(0, m_maxLen);
    
    strncpy( cvalue_p, trimmed.c_str(), m_maxLen);
    cvalue_p[trimmed.length()] = '\0';

    //
    // this_string is a pointer to this, but is a of a string type.
    // dynamic_cast is used, because it is intended for conversion
    // from derived class to a base class.
    //
    string *this_string = dynamic_cast<string*>(this);

    // string <-- string operator will be called
    *this_string = trimmed;
    
    return *this;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 88 of file rmdb.h.

Referenced by rm_DB::Connect(), rm_Operator::GetHost(), i_EfficientRecallJob_i::i_EfficientRecallJob_i(), i_MaintFriJob_i::i_MaintFriJob_i(), i_MigrationJob_i::i_MigrationJob_i(), i_RecallJob_i::i_RecallJob_i(), i_RedundantCopyJob_i::i_RedundantCopyJob_i(), i_ReorgJob_i::i_ReorgJob_i(), i_ThreadJob_i::i_ThreadJob_i(), rm_MajorCol::Insert(), rm_Partition::Insert(), rm_MediumVol::Insert(), rm_Medium::Insert(), rm_Slot::Insert(), rm_MediaPool::Insert(), rm_DiskSubsys::Insert(), rm_DriveHost::Insert(), rm_Drive::Insert(), rm_Library::Insert(), operator=(), rm_Operator::PoolInfo(), rm_Partition::Remove(), rm_DriveHost::Remove(), rm_String(), rm_Partition::Select(), rm_DriveHost::Select(), rm_Operator::SelectAllDriveHosts(), rm_Operator::SelectAllPart(), rm_Drive::SelectByAddr(), rm_Medium::SelectByBarcode(), rm_Slot::SelectByLibAddrType(), rm_MediumVol::SelectByMedVolId(), rm_Partition::SelectByName(), rm_MediaPool::SelectByName(), rm_DiskSubsys::SelectByName(), rm_Drive::SelectByName(), rm_Library::SelectByName(), rm_MediumVol::SelectByPartition(), rm_Medium::SelectByPartition(), rm_Partition::SelectByUuid(), rm_MediaPool::SelectByUUID(), rm_Operator::SelectDrive(), rm_Operator::SelectDriveHost(), rm_Operator::SelectLibrary(), rm_Operator::SelectMajorCol(), rm_Operator::SelectMediaPool(), rm_Operator::SelectMediaPoolbyUUID(), i_ResourceManager_i::SelectPartition(), i_ResourceManager_i::SelectPartitionByUUID(), rm_Partition::Update(), rm_MediumVol::Update(), rm_Medium::Update(), rm_Slot::Update(), rm_MediaPool::Update(), rm_DiskSubsys::Update(), rm_DriveHost::Update(), rm_Drive::Update(), rm_Library::Update(), and ~rm_String().

Definition at line 97 of file rmdb.h.

Definition at line 85 of file rmdb.h.

Referenced by operator=(), and rm_String().


The documentation for this class was generated from the following files: