update openddl-parser.

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
This commit is contained in:
Kim Kulling
2015-02-14 16:11:46 +01:00
parent bd1168af30
commit f5f0c9f7cf
2 changed files with 19 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ 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.
-----------------------------------------------------------------------------------------------*/
#include <openddlparser/Value.h>
#include <iostream>
#include <cassert>
@@ -109,6 +110,15 @@ double Value::getDouble() const {
return v;
}
void Value::setString( const std::string &str ) {
assert( ddl_string == m_type );
::memcpy( m_data, str.c_str(), str.size() );
m_data[ str.size() ] = '\0';
}
const char *Value::getString() const {
return (const char*) m_data;
}
void Value::dump() {
switch( m_type ) {
case ddl_none:
@@ -223,7 +233,11 @@ Value *ValueAllocator::allocPrimData( Value::ValueType type, size_t len ) {
}
if( data->m_size ) {
data->m_size *= len;
size_t len1( len );
if( Value::ddl_string == type ) {
len1++;
}
data->m_size *= len1;
data->m_data = new unsigned char[ data->m_size ];
}