oculus1

annotate libovr/Src/Kernel/OVR_String_FormatUtil.cpp @ 1:e2f9e4603129

added LibOVR and started a simple vr wrapper.
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Sep 2013 16:14:59 +0300
parents
children b069a5c27388
rev   line source
nuclear@1 1 /************************************************************************************
nuclear@1 2
nuclear@1 3 Filename : OVR_String_FormatUtil.cpp
nuclear@1 4 Content : String format functions.
nuclear@1 5 Created : February 27, 2013
nuclear@1 6 Notes :
nuclear@1 7
nuclear@1 8 Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
nuclear@1 9
nuclear@1 10 Use of this software is subject to the terms of the Oculus license
nuclear@1 11 agreement provided at the time of installation or download, or which
nuclear@1 12 otherwise accompanies this software in either electronic or hard copy form.
nuclear@1 13
nuclear@1 14 ************************************************************************************/
nuclear@1 15
nuclear@1 16 #include "OVR_String.h"
nuclear@1 17 #include "OVR_Log.h"
nuclear@1 18
nuclear@1 19 namespace OVR {
nuclear@1 20
nuclear@1 21 void StringBuffer::AppendFormat(const char* format, ...)
nuclear@1 22 {
nuclear@1 23 va_list argList;
nuclear@1 24
nuclear@1 25 va_start(argList, format);
nuclear@1 26 UPInt size = OVR_vscprintf(format, argList);
nuclear@1 27 va_end(argList);
nuclear@1 28
nuclear@1 29 char* buffer = (char*) OVR_ALLOC(sizeof(char) * (size+1));
nuclear@1 30
nuclear@1 31 va_start(argList, format);
nuclear@1 32 UPInt result = OVR_vsprintf(buffer, size+1, format, argList);
nuclear@1 33 OVR_UNUSED1(result);
nuclear@1 34 va_end(argList);
nuclear@1 35 OVR_ASSERT_LOG(result == size, ("Error in OVR_vsprintf"));
nuclear@1 36
nuclear@1 37 AppendString(buffer);
nuclear@1 38
nuclear@1 39 OVR_FREE(buffer);
nuclear@1 40 }
nuclear@1 41
nuclear@1 42 } // OVR