/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
//TODO: Temporary helper for STATIC_ARRAY_SELECT; ultimately, the latter should be replaced by a // proper function (template): template<typename T> constexpr std::make_unsigned_t<T> make_unsigned(T value) { if constexpr (std::is_signed_v<T>) { return o3tl::make_unsigned(value);
} else { return value;
}
}
}
/** Expands to the 'index'-th element of a STATIC data array, or to 'def', if
'index' is out of the array limits. */ #define STATIC_ARRAY_SELECT( array, index, def ) \
((detail::make_unsigned(index) < std::size(array)) ? ((array)[static_cast<size_t>(index)]) : (def))
// Common constants ===========================================================
const ::Color API_RGB_TRANSPARENT (ColorTransparency, 0xffffffff); ///< Transparent color for API calls. const sal_uInt32 UNSIGNED_RGB_TRANSPARENT = static_cast<sal_uInt32>(-1); ///< Transparent color for unsigned int32 places. const ::Color API_RGB_BLACK (0x000000); ///< Black color for API calls. const ::Color API_RGB_GRAY (0x808080); ///< Gray color for API calls. const ::Color API_RGB_WHITE (0xFFFFFF); ///< White color for API calls.
const sal_Int8 API_ESCAPEHEIGHT_NONE = 100; ///< Relative character height if not escaped. const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; ///< Relative character height if escaped.
// Read from bitfields --------------------------------------------------------
/** Returns true, if at least one of the bits set in nMask is set in nBitField. */ template< typename Type > inlinebool getFlag( Type nBitField, Type nMask )
{ return (nBitField & nMask) != 0;
}
/** Returns nSet, if at least one bit of nMask is set in nBitField, otherwise nUnset. */ template< typename ReturnType, typename Type > inline ReturnType getFlagValue( Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset )
{ return getFlag( nBitField, nMask ) ? nSet : nUnset;
}
/** Extracts a value from a bit field.
Returns the data fragment from nBitField, that starts at bit nStartBit (0-based, bit 0 is rightmost) with the width of nBitCount. The returned value will be right-aligned (normalized). For instance: extractValue<T>(0x4321,8,4) returns 3 (value in bits 8-11).
*/ template< typename ReturnType, typename Type > inline ReturnType extractValue( Type nBitField, sal_uInt8 nStartBit, sal_uInt8 nBitCount )
{
sal_uInt64 nMask = 1; nMask <<= nBitCount; --nMask; returnstatic_cast< ReturnType >( nMask & (nBitField >> nStartBit) );
}
// Write to bitfields ---------------------------------------------------------
/** Sets or clears (according to bSet) all set bits of nMask in ornBitField. */ template< typename Type > inlinevoid setFlag( Type& ornBitField, Type nMask, bool bSet = true )
{ if( bSet ) ornBitField |= nMask; else ornBitField &= ~nMask;
}
/** Provides platform independent functions to convert from or to little-endian byte order, e.g. for reading data from or writing data to memory or a binary stream.
On big-endian platforms, the byte order in the passed values is swapped, this can be used for converting big-endian to and from little-endian data.
#else template< typename Type > staticvoid convertLittleEndian( Type& ) {}
template< typename Type > staticvoid convertLittleEndianArray( Type*, size_t ) {}
#endif
/** Writes a value to memory, while converting it to little-endian. @param pDstBuffer The memory buffer to write the value to. @param nValue The value to be written to memory in little-endian.
*/ template< typename Type > inlinestaticvoid writeLittleEndian( void* pDstBuffer, Type nValue );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.