///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
// All rights reserved.
//
// This software and its documentation and related materials are owned by
// the Alliance. The software may only be incorporated into application
// programs owned by members of the Alliance, subject to a signed
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable
// trade secrets of the Alliance and its suppliers. The software is also
// protected by copyright law and international treaty provisions. Application
// programs incorporating this software must include the following statement
// with their copyright notices:
//
// This application incorporates Open Design Alliance software pursuant to a license
// agreement with Open Design Alliance.
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
// All rights reserved.
//
// By use of this software, its documentation or related materials, you
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
#ifndef _DAI_COMPRESSED_GUID_H_
#define _DAI_COMPRESSED_GUID_H_
#include "OdaCommon.h"
#include "OdAnsiString.h"
#include "daiBuildOptions.h"
#include "OdGUID.h"
#include "TD_PackPush.h"
/** \details
Implements the Data Access Interface (DAI) that provides functionality for manipulating data that is defined within the EXPRESS SCHEMA format.
*/
namespace OdDAI
{
/** \details
A class that implements generating and storing global unique identifiers (GUID) for Data Access Interface (DAI) objects.
*/
class DAI_EXPORT CompressedGUID
{
public:
/** \details
Creates a new Compressed GUID object with default parameters.
*/
CompressedGUID();
/** \details
Creates a new Compressed GUID based on an existing OdGUID value (copy constructor).
\param other [in] An OdGUID object that is used as a base for creating the Compressed GUID object.
*/
CompressedGUID(const OdGUID& other);
/** \details
Assignment operator for Compressed GUID objects.
\param s [in] A new Compressed GUID value to be assigned, represented as an ANSI string.
\returns A reference to the Compressed GUID object modified with the assignment operation.
*/
CompressedGUID& operator= (const OdAnsiString& s);
/** \details
Assignment operator for Compressed GUID objects.
\param other [in] A new GUID value to be assigned.
\returns A reference to the Compressed GUID object modified with the assignment operation.
*/
CompressedGUID& operator= (const OdGUID& other);
/** \details
Comparison operator for Compressed GUID objects.
\param other [in] Another Compressed GUID value to be compared with (right-hand operand).
\returns true if the Compressed GUID object is equal to another Compressed GUID object; otherwise, the method returns false.
*/
bool operator== (const CompressedGUID& other) const
{
return strncmp(m_val, other.m_val, 22) == 0;
};
/** \details
Inequality operator for Compressed GUID objects.
\param other [in] Another Compressed GUID value to be compared with (right-hand operand).
\returns true if the Compressed GUID object is not equal to another Compressed GUID object; otherwise, the method returns false.
*/
bool operator!= (const CompressedGUID& other) const
{
return !(this->operator == (other));
};
/** \details
The "less-than" operator for Compressed GUID objects.
\param other [in] Another Compressed GUID value to be compared with (right-hand operand).
\returns true if the Compressed GUID value is less than the compared Compressed GUID value; otherwise the operator returns false.
\remarks
The Compressed GUID is less than another Compressed GUID if the string representation of the Compressed GUID is not equal to the string representation
of another Compressed GUID and the code of the first symbol that differs is less than the symbol code
in the same position in the string representation of the compared Compressed GUID.
*/
bool operator< (const CompressedGUID& other) const
{
return strncmp(m_val, other.m_val, 22) < 0;
};
/** \details
Converts the Compressed GUID object's value to a constant C++ character array.
\returns A raw pointer to the C++ character array that contains the string with the Compressed GUID value.
*/
operator const char* () const;
/** \details
Converts the Compressed GUID object's value to a C++ character array.
\returns A raw pointer to the C++ character array.
*/
operator char* ();
/** \details
Retrieves the constant raw pointer to the underlying string.
\returns A raw pointer to the C++ character array.
*/
const char* c_str() const { return m_val; };
/** \details
Determines whether the Compressed GUID value is valid.
\returns true if the value is valid; otherwise the method returns false.
*/
bool isValid() const;
/** \details
Generates a new Compressed GUID object (pseudo constructor).
\returns The generated GUID object.
*/
static CompressedGUID generate();
//DOM-IGNORE-BEGIN
private:
char m_val[23];
//DOM-IGNORE-END
};
/** \details
Contains declarations and definitions for different utils that implement useful helper functionality for Data Access Interface (DAI).
*/
namespace Utils
{
#if defined (__cplusplus)
extern "C" {
#endif
/** \details
Creates the string representation of the GUID.
\param buf [out] A raw pointer to the data buffer that contains the string representation.
\param len [in] A usable length of the output buffer.
\returns
A pointer to the character buffer with the zero-terminated string representation of the GUID; otherwise, the function returns NULL.
\remarks
The buffer must be able to hold 22 characters + 1 for the terminating 0.
*/
char* createCompressedGuidString(char* buf, int len);
//char * String64_To_HexaGuidString( const char *string64, char * buf, int len ); // len >= 39
//char * String64_To_String85( const char *string64, char * buf, int len ); // len >= 21
//char * String85_To_String64( const char *string85, char * buf, int len ); // len >= 23
#if defined (__cplusplus)
}
#endif
}
}
#include "TD_PackPop.h"
#endif // _DAI_COMPRESSED_GUID_H_