1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: os_Utility.cpp
4
5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain proprietary
8 information of Nintendo and/or its licensed developers and are protected by
9 national and international copyright laws. They may not be disclosed to third
10 parties or copied or duplicated in any form, in whole or in part, without the
11 prior written consent of Nintendo.
12
13 The content herein is highly confidential and should be handled accordingly.
14
15 $Revision: 31311 $
16 *---------------------------------------------------------------------------*/
17
18 #include "precompiled.h"
19
20 #include <nw/types.h>
21 #include <nw/os/os_Utility.h>
22
23 #if 1
24 // NW_ADAPTIVE_HEADER マクロが使用可能な場合の処理。
25 #include <nw/config/macros.h>
26
27 #include NW_ADAPTIVE_HEADER_LOCAL(./platform/os_Utility, NW_PLATFORM_NAME.cpp)
28
29 #else
30 // 使用が不可であれば、#if文の羅列で代替する。
31
32 #if defined( NW_PLATFORM_RVL )
33 #include "./platform/os_UtilityRVL.cpp"
34 #elif defined( NW_PLATFORM_TWL )
35 #include "./platform/os_UtilityTWL.cpp"
36 #elif defined( NW_PLATFORM_CTR )
37 #include "./platform/os_UtilityCTR.cpp"
38 #elif defined( NW_PLATFORM_CTRWIN )
39 #include "./platform/os_UtilityCTRWIN.cpp"
40 #elif defined( NW_PLATFORM_WIN32 )
41 #include "./platform/os_UtilityWIN32.cpp"
42 #else
43
44 #error "Unknown platform"
45
46 #endif
47
48 #endif
49
50
51 namespace nw {
52 namespace os {
53 namespace internal {
54
55 /*!--------------------------------------------------------------------------*
56 Name: Printf
57
58 @brief 書式付き文字列を出力します。
59
60 @param[in] fmt 出力文字列フォーマット
61
62 @return None.
63 *---------------------------------------------------------------------------*/
64 NW_WEAK_SYMBOL void
Printf(const char * fmt,...)65 Printf(const char *fmt, ...)
66 {
67 std::va_list vlist;
68 va_start(vlist, fmt);
69
70 VPrintf(fmt, vlist);
71
72 va_end(vlist);
73 }
74
75 /*!--------------------------------------------------------------------------*
76 Name: Warning
77
78 @brief ワーニングを出力します。
79
80 @param[in] fileName Warning の発生したソースファイル名
81 @param[in] line Warning の発生した行番号
82 @param[in] fmt 出力文字列フォーマット
83
84 @return None.
85 *---------------------------------------------------------------------------*/
86 NW_WEAK_SYMBOL void
Warning(const char * fileName,int line,const char * fmt,...)87 Warning( const char* fileName, int line, const char* fmt, ...)
88 {
89 va_list vlist;
90 va_start(vlist, fmt);
91
92 Printf("%s:%d Warning:", fileName, line);
93 VPrintf(fmt, vlist);
94 Printf("\n");
95
96 va_end(vlist);
97 }
98
99 /*!--------------------------------------------------------------------------*
100 Name: Panic
101
102 @brief メッセージを出力して停止します。
103
104 @param[in] fileName Panic の発生したソースファイル名
105 @param[in] line Panic の発生した行番号
106 @param[in] fmt 出力文字列フォーマット
107
108 @return None.
109 *---------------------------------------------------------------------------*/
110 NW_WEAK_SYMBOL void
Panic(const char * fileName,int line,const char * fmt,...)111 Panic( const char* fileName, int line, const char* fmt, ...)
112 {
113 std::va_list vlist;
114 va_start(vlist, fmt);
115
116 Printf("%s:%d Panic:", fileName, line);
117 VPrintf(fmt, vlist);
118 Printf("\n");
119
120 va_end(vlist);
121
122 Halt();
123 }
124
125 } // namespace internal
126
127 /*!--------------------------------------------------------------------------*
128 Name: SNPrintf
129
130 @brief 与えられたバッファへ書式付き文字列を出力します。
131
132 @param[out] dst 出力先バッファ
133 @param[in] len 出力先バッファサイズ
134 @param[in] fmt 出力文字列フォーマット
135
136 @return 出力文字列の文字列長 ('\0'を除く)
137 *---------------------------------------------------------------------------*/
138 int
SNPrintf(char * dst,size_t len,const char * fmt,...)139 SNPrintf(char* dst, size_t len, const char* fmt, ...)
140 {
141 std::va_list vlist;
142 va_start(vlist, fmt);
143
144 int ret = VSNPrintf(dst, len, fmt, vlist);
145
146 va_end(vlist);
147 return ret;
148 }
149
150 } // namespace os
151 } // namespace nw
152
153
154