// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // »Project« Talina Gaming System (TgS) (∂) // »File« TgS Common - Base - Type.inl // »Author« Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com) // »Version« 4.0 // ------------------------------------------------------------------------------------------------------------------------------ // // Copyright: © 2002-2010, Andrew Aye. All Rights Reserved. // This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. // Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following // disclaimers in the documentation and other materials provided with the distribution. // Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // The intellectual property rights of the algorithms used reside with Andrew Aye. You may not use this software, in whole or // in part, in support of any commercial product without the express written consent of the author. // There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is". // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // #if !defined(_TGS_COMMON_BASE_TYPES_INL_) #define _TGS_COMMON_BASE_TYPES_INL_ #pragma once // START TGS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define BITFIELD_IMPL( CLASS, TYPE, SIZE ) \ TgINLINE TgVOID tgBF_Set_Flag_##CLASS ( PCU_##TYPE ptyBF, C_TgUINT32 uiFlag, C_TgBOOL bFlag ) { \ TgASSERT( uiFlag < SIZE ); \ *ptyBF = bFlag ? (*ptyBF | (1<<uiFlag)) : (*ptyBF & ~(1<<uiFlag)); \ } \ TgINLINE TgVOID tgBF_Toggle_Flag_##CLASS ( PCU_##TYPE ptyBF, C_TgUINT32 uiFlag ) { \ TgASSERT( uiFlag < SIZE ); \ *ptyBF ^= (1<<uiFlag); \ } \ TgINLINE TgBOOL tgBF_Query_Flag_##CLASS ( CPCU_##TYPE ptyBF, C_TgUINT32 uiFlag ) { \ TgASSERT( uiFlag < SIZE ); \ return( 0 != (*ptyBF & (1<<uiFlag)) ); \ } \ TgINLINE TgVOID tgBF_Reset_##CLASS ( PCU_##TYPE ptyBF ) { *ptyBF = 0; } BITFIELD_IMPL( U08, TgUINT08, 8 ) BITFIELD_IMPL( U16, TgUINT16, 16 ) BITFIELD_IMPL( U32, TgUINT32, 32 ) #undef BITFIELD_IMPL TgINLINE TgVOID tgBF_Set_Flag_U64( PCU_TgUINT64 ptyBF, C_TgUINT32 uiFlag, C_TgBOOL bFlag ) { TgASSERT( uiFlag < 64 ); *ptyBF = bFlag ? (*ptyBF | (1ULL<<uiFlag)) : (*ptyBF & ~(1ULL<<uiFlag)); } TgINLINE TgVOID tgBF_Toggle_Flag_U64( PCU_TgUINT64 ptyBF, C_TgUINT32 uiFlag ) { TgASSERT( uiFlag < 64 ); *ptyBF ^= (1ULL<<uiFlag); } TgINLINE TgBOOL tgBF_Query_Flag_U64( CPCU_TgUINT64 ptyBF, C_TgUINT32 uiFlag ) { TgASSERT( uiFlag < 64 ); return( 0ULL != (*ptyBF & (1ULL<<uiFlag)) ); } TgINLINE TgVOID tgBF_Reset_U64( PCU_TgUINT64 ptyBF ) { *ptyBF = 0ULL; } TgINLINE TgVOID tgPath_Check_File_Block_With_Assert( CPCU_STg2_File_Block ptgFB ) { TgASSERT( TgFOURCC('T','G','S','F') == ptgFB->m_uiFourCC ); TgASSERT( sizeof(STg2_File_Block) == ptgFB->m_uiSize ); TgASSERT( 0x01 == ptgFB->m_uiVersion ); TgASSERT( 0x01 == ptgFB->m_uiSection_Version ); TgASSERT( sizeof(STg2_File_Section) == ptgFB->m_uiSection_Size ); } #endif // END ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////