summaryrefslogtreecommitdiff
path: root/XMPCommon/source/IUTF8StringComparator.cpp
blob: d4398c8426489587c4a4fe184bb9770d3f68ddbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// =================================================================================================
// Copyright Adobe
// Copyright 2015 Adobe
// 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;
	}

}