add morkEnv::HexToByte()
This commit is contained in:
Родитель
37672509d1
Коммит
740c1e83a6
|
@ -28,6 +28,10 @@
|
|||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCH_
|
||||
#include "morkCh.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
@ -182,6 +186,31 @@ morkEnv::OidAsHex(void* outBuf, const mdbOid& inOid)
|
|||
return idSize + scopeSize + 2;
|
||||
}
|
||||
|
||||
|
||||
mork_u1
|
||||
morkEnv::HexToByte(mork_ch inFirstHex, mork_ch inSecondHex)
|
||||
{
|
||||
mork_u1 hi = 0; // high four hex bits
|
||||
mork_flags f = morkCh_GetFlags(inFirstHex);
|
||||
if ( morkFlags_IsDigit(f) )
|
||||
hi = inFirstHex - '0';
|
||||
else if ( morkFlags_IsUpper(f) )
|
||||
hi = (inFirstHex - 'A') + 10;
|
||||
else if ( morkFlags_IsLower(f) )
|
||||
hi = (inFirstHex - 'a') + 10;
|
||||
|
||||
mork_u1 lo = 0; // low four hex bits
|
||||
f = morkCh_GetFlags(inSecondHex);
|
||||
if ( morkFlags_IsDigit(f) )
|
||||
lo = inSecondHex - '0';
|
||||
else if ( morkFlags_IsUpper(f) )
|
||||
lo = (inSecondHex - 'A') + 10;
|
||||
else if ( morkFlags_IsLower(f) )
|
||||
lo = (inSecondHex - 'a') + 10;
|
||||
|
||||
return (mork_u1) ((hi << 4) | lo);
|
||||
}
|
||||
|
||||
mork_size
|
||||
morkEnv::TokenAsHex(void* outBuf, mork_token inToken)
|
||||
// TokenAsHex() is the same as sprintf(outBuf, "%lX", (long) inToken);
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
#include "morkNode.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKCH_
|
||||
#include "morkCh.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MORKENV_
|
||||
#include "morkEnv.h"
|
||||
#endif
|
||||
|
@ -182,6 +186,31 @@ morkEnv::OidAsHex(void* outBuf, const mdbOid& inOid)
|
|||
return idSize + scopeSize + 2;
|
||||
}
|
||||
|
||||
|
||||
mork_u1
|
||||
morkEnv::HexToByte(mork_ch inFirstHex, mork_ch inSecondHex)
|
||||
{
|
||||
mork_u1 hi = 0; // high four hex bits
|
||||
mork_flags f = morkCh_GetFlags(inFirstHex);
|
||||
if ( morkFlags_IsDigit(f) )
|
||||
hi = inFirstHex - '0';
|
||||
else if ( morkFlags_IsUpper(f) )
|
||||
hi = (inFirstHex - 'A') + 10;
|
||||
else if ( morkFlags_IsLower(f) )
|
||||
hi = (inFirstHex - 'a') + 10;
|
||||
|
||||
mork_u1 lo = 0; // low four hex bits
|
||||
f = morkCh_GetFlags(inSecondHex);
|
||||
if ( morkFlags_IsDigit(f) )
|
||||
lo = inSecondHex - '0';
|
||||
else if ( morkFlags_IsUpper(f) )
|
||||
lo = (inSecondHex - 'A') + 10;
|
||||
else if ( morkFlags_IsLower(f) )
|
||||
lo = (inSecondHex - 'a') + 10;
|
||||
|
||||
return (mork_u1) ((hi << 4) | lo);
|
||||
}
|
||||
|
||||
mork_size
|
||||
morkEnv::TokenAsHex(void* outBuf, mork_token inToken)
|
||||
// TokenAsHex() is the same as sprintf(outBuf, "%lX", (long) inToken);
|
||||
|
|
Загрузка…
Ссылка в новой задаче