diff options
Diffstat (limited to 'XMPCommon/source/IUTF8StringComparator.cpp')
-rw-r--r-- | XMPCommon/source/IUTF8StringComparator.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/XMPCommon/source/IUTF8StringComparator.cpp b/XMPCommon/source/IUTF8StringComparator.cpp new file mode 100644 index 0000000..c7fe411 --- /dev/null +++ b/XMPCommon/source/IUTF8StringComparator.cpp @@ -0,0 +1,26 @@ +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2015 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/Utilities/IUTF8StringComparator.h" +#include "XMPCommon/Interfaces/IUTF8String.h" +#include <algorithm> +#include <cstring> +namespace XMP_COMPONENT_INT_NAMESPACE { + + bool IUTF8StringComparator::operator()( const spcIUTF8String & left, const spcIUTF8String & right ) const { + sizet str1Size = left->size(), str2Size = right->size(); + int result = strncmp( left->c_str(), right->c_str(), std::min( str1Size, str2Size ) ); + if ( result == 0 && str1Size != str2Size ) + return str1Size < str2Size; + if ( result < 0 ) + return true; + return false; + } + +} |