Changeset 452
- Timestamp:
- 04/09/07 02:06:44 (16 years ago)
- Files:
-
- trunk/libffado/src/libosc/OscArgument.cpp (modified) (1 diff)
- trunk/libffado/src/libosc/OscArgument.h (modified) (1 diff)
- trunk/libffado/src/libosc/unittests.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libosc/OscArgument.cpp
r445 r452 91 91 } 92 92 93 int32_t 94 OscArgument::toInt() { 95 if(m_isInt) { 96 return m_intVal; 97 } else if(m_isInt64) { 98 return (int32_t)(m_int64Val & 0xFFFFFFFF); 99 } else if(m_isFloat) { 100 return (int32_t)(m_floatVal); 101 } else { 102 return 0; 103 } 104 } 105 106 int64_t 107 OscArgument::toInt64() { 108 if(m_isInt) { 109 return (int64_t)(m_intVal); 110 } else if(m_isInt64) { 111 return m_int64Val; 112 } else if(m_isFloat) { 113 return (int64_t)(m_floatVal); 114 } else { 115 return 0; 116 } 117 } 118 119 float 120 OscArgument::toFloat() { 121 if(m_isInt) { 122 return (float)(m_intVal); 123 } else if(m_isInt64) { 124 return (float)(m_int64Val); 125 } else if(m_isFloat) { 126 return m_floatVal; 127 } else { 128 return 0; 129 } 130 } 131 93 132 void 94 133 OscArgument::print() trunk/libffado/src/libosc/OscArgument.h
r445 r452 45 45 bool operator == ( const OscArgument& rhs ); 46 46 47 /** 48 * @brief Returns the argument's integer value 49 * @return 32 bit integer argument value 50 */ 47 51 int32_t getInt() { return m_intVal;}; 52 /** 53 * @brief Returns the argument's value converted to integer. 54 * if the argument type is float or int64 it will be 55 * cast (and trunctacted) to 32bit integer 56 * @return 57 */ 58 int32_t toInt(); 59 /** 60 * @brief Is the argument a 32 bit integer? 61 * @return true if the argument is a 32 bit integer 62 */ 48 63 bool isInt() { return m_isInt;}; 64 65 /** 66 * @brief Returns the argument's 64 bit integer value 67 * @return 64 bit integer argument value 68 */ 49 69 int64_t getInt64() { return m_int64Val;}; 70 /** 71 * @brief Returns the argument's value converted to a 64bit integer. 72 * if the argument type is float or int it will be 73 * cast to a 64 bit integer 74 * @return 75 */ 76 int64_t toInt64(); 77 /** 78 * @brief Is the argument a 64 bit integer? 79 * @return true if the argument is a 64 bit integer 80 */ 50 81 bool isInt64() { return m_isInt64;}; 82 83 /** 84 * @brief Returns the argument's float value 85 * @return float argument value 86 */ 51 87 float getFloat() { return m_floatVal;}; 88 /** 89 * @brief Returns the argument's value converted to float. 90 * if the argument type is int32 or int64 it will be 91 * cast to a float 92 * @return 93 */ 94 float toFloat(); 95 /** 96 * @brief Is the argument a float? 97 * @return true if the argument is a float 98 */ 52 99 bool isFloat() { return m_isFloat;}; 100 101 /** 102 * @brief Returns the argument's string value 103 * @return string argument value 104 */ 53 105 string& getString() { return m_stringVal;}; 106 /** 107 * @brief Is the argument a string? 108 * @return true if the argument is a string 109 */ 54 110 bool isString() { return m_isString;}; 111 112 113 /** 114 * @brief Is the argument a numeric? 115 * @return true if the argument is a numeric value 116 */ 117 bool isNumeric() { return (m_isInt|| m_isInt64 || m_isFloat);}; 118 55 119 56 120 void print(); trunk/libffado/src/libosc/unittests.cpp
r445 r452 63 63 result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(1).getString()==string("teststring")); 64 64 result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(2).getInt()==1); 65 65 66 result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(0).toInt()==1); 67 66 68 return result; 67 69 }