openddl-parser: V0.2.0

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/552/head
Kim Kulling 2015-05-05 22:26:40 +02:00
parent 5357772cf5
commit 2c60da38f3
6 changed files with 23 additions and 35 deletions

View File

@ -101,12 +101,11 @@ uint8 Value::getUnsignedInt8() const {
void Value::setUnsignedInt16( uint16 value ) { void Value::setUnsignedInt16( uint16 value ) {
assert( ddl_unsigned_int16 == m_type ); assert( ddl_unsigned_int16 == m_type );
::memcpy( m_data, &value, m_size ); ::memcpy( m_data, &value, m_size );
} }
uint16 Value::getUnsignedInt16() const { uint16 Value::getUnsignedInt16() const {
assert( ddl_unsigned_int16 == m_type ); assert( ddl_unsigned_int16 == m_type );
return ( uint8 ) ( *m_data ); return ( uint8 ) ( *m_data );
} }
void Value::setUnsignedInt32( uint32 value ) { void Value::setUnsignedInt32( uint32 value ) {
@ -135,9 +134,15 @@ void Value::setFloat( float value ) {
} }
float Value::getFloat() const { float Value::getFloat() const {
if( m_type == ddl_float ) {
float v; float v;
::memcpy( &v, m_data, m_size ); ::memcpy( &v, m_data, m_size );
return v; return ( float ) v;
} else {
float tmp;
::memcpy( &tmp, m_data, 4 );
return ( float ) tmp;
}
} }
void Value::setDouble( double value ) { void Value::setDouble( double value ) {
@ -241,7 +246,7 @@ Value *ValueAllocator::allocPrimData( Value::ValueType type, size_t len ) {
data->m_size = sizeof( int ); data->m_size = sizeof( int );
break; break;
case Value::ddl_int64: case Value::ddl_int64:
data->m_size = sizeof( long ); data->m_size = sizeof( int64 );
break; break;
case Value::ddl_unsigned_int8: case Value::ddl_unsigned_int8:
data->m_size = sizeof( unsigned char ); data->m_size = sizeof( unsigned char );
@ -250,7 +255,7 @@ Value *ValueAllocator::allocPrimData( Value::ValueType type, size_t len ) {
data->m_size = sizeof( unsigned int ); data->m_size = sizeof( unsigned int );
break; break;
case Value::ddl_unsigned_int64: case Value::ddl_unsigned_int64:
data->m_size = sizeof( unsigned long ); data->m_size = sizeof( uint64 );
break; break;
case Value::ddl_half: case Value::ddl_half:
data->m_size = sizeof( short ); data->m_size = sizeof( short );

View File

@ -21,8 +21,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------------*/
#pragma once #pragma once
#ifndef OPENDDLPARSER_DDLNODE_H_INC
#define OPENDDLPARSER_DDLNODE_H_INC
#include <openddlparser/OpenDDLCommon.h> #include <openddlparser/OpenDDLCommon.h>
@ -88,5 +86,3 @@ private:
}; };
END_ODDLPARSER_NS END_ODDLPARSER_NS
#endif // OPENDDLPARSER_DDLNODE_H_INC

View File

@ -21,14 +21,15 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------------*/
#pragma once #pragma once
#ifndef OPENDDLPARSER_OPENDDLPARSERCOMMON_H_INC
#define OPENDDLPARSER_OPENDDLPARSERCOMMON_H_INC
#include <cstddef> #include <cstddef>
#include <vector> #include <vector>
#include <string> #include <string>
#include <string.h> #include <string.h>
#ifndef _WIN32
# include <inttypes.h>
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
# define TAG_DLL_EXPORT __declspec(dllexport) # define TAG_DLL_EXPORT __declspec(dllexport)
@ -67,11 +68,17 @@ struct DataArrayList;
typedef char int8; typedef char int8;
typedef short int16; typedef short int16;
typedef int int32; typedef int int32;
typedef long int64;
typedef unsigned char uint8; typedef unsigned char uint8;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef unsigned int uint32; typedef unsigned int uint32;
typedef unsigned long uint64;
#ifdef _WIN32
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
typedef int64_t int64;
typedef uint64_t uint64;
#endif
enum NameType { enum NameType {
GlobalName, GlobalName,
@ -248,6 +255,3 @@ private:
}; };
END_ODDLPARSER_NS END_ODDLPARSER_NS
#endif // OPENDDLPARSER_OPENDDLPARSERCOMMON_H_INC

View File

@ -21,8 +21,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------------*/
#pragma once #pragma once
#ifndef OPENDDLPARSER_OPENDDLPARSER_H_INC
#define OPENDDLPARSER_OPENDDLPARSER_H_INC
#include <openddlparser/OpenDDLCommon.h> #include <openddlparser/OpenDDLCommon.h>
#include <openddlparser/DDLNode.h> #include <openddlparser/DDLNode.h>
@ -127,5 +125,3 @@ private:
}; };
END_ODDLPARSER_NS END_ODDLPARSER_NS
#endif // OPENDDLPARSER_OPENDDLPARSER_H_INC

View File

@ -21,8 +21,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------------*/
#pragma once #pragma once
#ifndef OPENDDLPARSER_OPENDDLPARSERUTILS_H_INC
#define OPENDDLPARSER_OPENDDLPARSERUTILS_H_INC
#include <openddlparser/OpenDDLCommon.h> #include <openddlparser/OpenDDLCommon.h>
@ -124,7 +122,6 @@ bool isInteger( T *in, T *end ) {
bool result( false ); bool result( false );
while( isNotEndOfToken( in, end ) ) { while( isNotEndOfToken( in, end ) ) {
//while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) {
result = isNumeric( *in ); result = isNumeric( *in );
if( !result ) { if( !result ) {
break; break;
@ -147,8 +144,6 @@ bool isFloat( T *in, T *end ) {
// check for <1>.0f // check for <1>.0f
bool result( false ); bool result( false );
while( isNotEndOfToken( in, end ) ) { while( isNotEndOfToken( in, end ) ) {
// while( !isSpace( *in ) && in != end ) {
if( *in == '.' ) { if( *in == '.' ) {
result = true; result = true;
break; break;
@ -169,8 +164,6 @@ bool isFloat( T *in, T *end ) {
// check for 1.<0>f // check for 1.<0>f
while( isNotEndOfToken( in, end ) ) { while( isNotEndOfToken( in, end ) ) {
// while( !isSpace( *in ) && in != end && *in != ',' && *in != '}' ) {
result = isNumeric( *in ); result = isNumeric( *in );
if( !result ) { if( !result ) {
return false; return false;
@ -257,5 +250,3 @@ int hex2Decimal( char in ) {
} }
END_ODDLPARSER_NS END_ODDLPARSER_NS
#endif // OPENDDLPARSER_OPENDDLPARSERUTILS_H_INC

View File

@ -21,8 +21,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------------------------*/
#pragma once #pragma once
#ifndef OPENDDLPARSER_VALUE_H_INC
#define OPENDDLPARSER_VALUE_H_INC
#include <openddlparser/OpenDDLCommon.h> #include <openddlparser/OpenDDLCommon.h>
@ -101,5 +99,3 @@ struct DLL_ODDLPARSER_EXPORT ValueAllocator {
}; };
END_ODDLPARSER_NS END_ODDLPARSER_NS
#endif // OPENDDLPARSER_VALUE_H_INC