// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

//=================================================================================================

inline void TCollection_HAsciiString::AssignCat(const char* const other)
{
  myString.AssignCat(other);
}

//=================================================================================================

inline void TCollection_HAsciiString::AssignCat(const occ::handle<TCollection_HAsciiString>& other)
{
  myString.AssignCat(other->String());
}

//=================================================================================================

inline int TCollection_HAsciiString::Length() const
{
  return myString.Length();
}

//=================================================================================================

inline const TCollection_AsciiString& TCollection_HAsciiString::String() const
{
  return myString;
}

// ----------------------------------------------------------------------------
inline const char* TCollection_HAsciiString::ToCString() const
{
  return myString.ToCString();
}

namespace std
{
template <>
struct hash<occ::handle<TCollection_HAsciiString>>
{
  size_t operator()(const occ::handle<TCollection_HAsciiString>& theString) const
  {
    if (theString.IsNull())
      return 0;
    return std::hash<TCollection_AsciiString>{}(theString->String());
  }
};

template <>
struct equal_to<occ::handle<TCollection_HAsciiString>>
{
  bool operator()(const occ::handle<TCollection_HAsciiString>& theString1,
                  const occ::handle<TCollection_HAsciiString>& theString2) const
  {
    return theString1 == theString2
           || (!theString1.IsNull() && !theString2.IsNull()
               && theString1->String() == theString2->String());
  }
};
} // namespace std
