lessoperators.cxx (37adc4f0) lessoperators.cxx (7f80ef06)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 22 unchanged lines hidden (view full) ---

31#include "sal/types.h"
32#include "typelib/typeclass.h"
33#include "typelib/typedescription.hxx"
34
35#include "lessoperators.hxx"
36
37namespace com { namespace sun { namespace star { namespace uno {
38
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 22 unchanged lines hidden (view full) ---

31#include "sal/types.h"
32#include "typelib/typeclass.h"
33#include "typelib/typedescription.hxx"
34
35#include "lessoperators.hxx"
36
37namespace com { namespace sun { namespace star { namespace uno {
38
39bool operator <(TypeDescription const & left, TypeDescription const & right) {
40 OSL_ASSERT(left.is() && right.is());
41 typelib_TypeClass tc1 = left.get()->eTypeClass;
42 typelib_TypeClass tc2 = right.get()->eTypeClass;
43 return tc1 < tc2 ||
44 (tc1 == tc2 &&
45 (rtl::OUString(left.get()->pTypeName) <
46 rtl::OUString(right.get()->pTypeName)));
39bool operator<( const TypeDescription& rLeft, const TypeDescription& rRight) {
40 OSL_ASSERT( rLeft.is() && rRight.is());
41 const typelib_TypeDescription& rA = *rLeft.get();
42 const typelib_TypeDescription& rB = *rRight.get();
43 if( rA.eTypeClass != rA.eTypeClass)
44 return (rA.eTypeClass < rB.eTypeClass);
45 const sal_Int32 nCmp = rtl_ustr_compare_WithLength(
46 rA.pTypeName->buffer, rA.pTypeName->length,
47 rB.pTypeName->buffer, rB.pTypeName->length);
48 return (nCmp < 0);
47}
48
49}
50
51bool TypeDescEqual::operator()( const TypeDescription& rLeft, const TypeDescription& rRight) const
52{
53 OSL_ASSERT( rLeft.is() && rRight.is());
54 const typelib_TypeDescription& rA = *rLeft.get();
55 const typelib_TypeDescription& rB = *rRight.get();
56 if( rA.eTypeClass != rB.eTypeClass)
57 return false;
58 const sal_Int32 nCmp = rtl_ustr_compare_WithLength(
59 rA.pTypeName->buffer, rA.pTypeName->length,
60 rB.pTypeName->buffer, rB.pTypeName->length);
61 return (nCmp == 0);
62}
63
64sal_Int32 TypeDescHash::operator()( const TypeDescription& rTD) const
65{
66 OSL_ASSERT( rTD.is());
67 const typelib_TypeDescription& rA = *rTD.get();
68 sal_Int32 h = rtl_ustr_hashCode_WithLength( rA.pTypeName->buffer, rA.pTypeName->length);
69 h ^= static_cast<sal_Int32>(rA.eTypeClass);
70 return h;
71}
72
49} } } }
50
51namespace rtl {
52
53bool operator <(ByteSequence const & left, ByteSequence const & right) {
73} } } }
74
75namespace rtl {
76
77bool operator <(ByteSequence const & left, ByteSequence const & right) {
54 for (sal_Int32 i = 0; i != std::min(left.getLength(), right.getLength());
55 ++i)
78 const sal_Int32 nLen = std::min( left.getLength(), right.getLength());
79 for( sal_Int32 i = 0; i < nLen; ++i )
56 {
57 if (left[i] < right[i]) {
58 return true;
59 }
60 if (right[i] < left[i]) {
61 return false;
62 }
63 }
64 return left.getLength() < right.getLength();
65}
66
67}
80 {
81 if (left[i] < right[i]) {
82 return true;
83 }
84 if (right[i] < left[i]) {
85 return false;
86 }
87 }
88 return left.getLength() < right.getLength();
89}
90
91}
92