Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_String_FormatUtil.cpp
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : OVR_String_FormatUtil.cpp
4 Content : String format functions.
5 Created : February 27, 2013
6 Notes :
7 
8 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 
10 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
12 which is provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
14 
15 You may obtain a copy of the License at
16 
17 http://www.oculusvr.com/licenses/LICENSE-3.1
18 
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
24 
25 ************************************************************************************/
26 
27 #include "OVR_String.h"
28 #include "OVR_Log.h"
29 
30 namespace OVR {
31 
32 void StringBuffer::AppendFormat(const char* format, ...)
33 {
34  va_list argList;
35 
36  va_start(argList, format);
37  UPInt size = OVR_vscprintf(format, argList);
38  va_end(argList);
39 
40  char* buffer = (char*) OVR_ALLOC(sizeof(char) * (size+1));
41 
42  va_start(argList, format);
43  UPInt result = OVR_vsprintf(buffer, size+1, format, argList);
44  OVR_UNUSED1(result);
45  va_end(argList);
46  OVR_ASSERT_LOG(result == size, ("Error in OVR_vsprintf"));
47 
48  AppendString(buffer);
49 
50  OVR_FREE(buffer);
51 }
52 
53 } // OVR
UPInt OVR_CDECL OVR_vsprintf(char *dest, UPInt destsize, const char *format, va_list argList)
Definition: OVR_Std.h:304
#define OVR_ASSERT_LOG(c, args)
Definition: OVR_Log.h:198
size_t UPInt
Definition: OVR_Types.h:218
#define OVR_UNUSED1(a1)
void AppendFormat(const char *format,...)
#define OVR_ALLOC(s)
UPInt OVR_CDECL OVR_vscprintf(const char *format, va_list argList)
Definition: OVR_Std.h:334
#define OVR_FREE(p)
void AppendString(const wchar_t *pstr, SPInt len=-1)
Definition: OVR_String.cpp:680