Develop and Download Open Source Software

Browse CVS Repository

Contents of /xoonips/AL/common.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Fri Nov 26 03:29:43 2004 UTC (19 years, 4 months ago) by aga
Branch: MAIN
Changes since 1.1: +23 -2 lines
File MIME type: text/x-c++src
・intToString()を作成.

1 /*
2 * Abstract Layer????罘??純?????鋎帥???∽?違???????у?臂?????鐚?/span>
3 *
4 * $Revision: 1.1 $
5 * $Log: common.cc,v $
6 * Revision 1.1 2004/11/22 08:25:16 youi
7 * initial version.
8 *
9 *
10 */
11
12 #include <stdio.h>
13 #include <string.h>
14 #include "common.h"
15
16 /**
17 *
18 * 筝???????????絖?????茲?茖純??鐚??????≪?????鴻??菴???鐚?/span>
19 *
20 * @param text
21 * @return 茲?茖純??????絖??????≪??????/span>
22 * @return 0 茲?茖純??け??
23 *
24 */
25 char* str_dup( const char* text )
26 {
27 if( text == 0 ) return 0;
28 char* ptr = new char[ strlen( text ) + 1 ];
29 if( ptr == 0 ) return 0;
30 strcpy( ptr , text );
31 return ptr;
32 }
33
34 /**
35 *
36 * newtext?ф??絎?????????絖?????茲?茖純??鐚??????≪?????鴻??*dstptr??撮?ャ????.<br>
37 * ??????????鐚??????障??dstptr?????с??????????????茹f?障????.<br>
38 * ??筝??уけ???????翫????dstptr????絎鴻???吾??????????????鐚?lt;br>
39 * newtext==0?????????*dstptr?????с??????????茹f?障??鐚?腥堺??絖????域???????????????≪?????鴻??*dstptr??撮?ャ????.<br>
40 *
41 * @param newtext *dstptr??撮?ャ????????絖???
42 * @param dstptr 茲?茖純????newtext???≪?????鴻??篁e?ャ???????ゃ?潟?水??違?吾?????ゃ?潟??/span>
43 * @return dstptr??撮?ャ?????≪????? 紊掩??????????????stptr
44 *
45 */
46 char* setValue( char** dstptr, const char* newtext )
47 {
48 char* ptr;
49
50 // newtext??0????鐚?*dstptr?????с?????<?≪????????茹f?障??鐚?
51 // *dstptr?????域?篏???????腥堺??絖????≪?????鴻??篁e??/span>
52 if( newtext == 0 ){
53 ptr = str_dup( "" );
54 }else{
55 ptr = str_dup( newtext );
56 }
57 if( ptr != 0 ){
58 if( *dstptr != 0 ) delete[] *dstptr;
59 *dstptr = ptr;
60 }
61 return *dstptr;
62 }
63
64 /**
65 *
66 * int????絖??????????
67 *
68 * @param i 紊??????鴻???医??/span>
69 * @return 紊???緇?????絖???
70 *
71 */
72 string intToString( int i ){
73 char buf[sizeof(int)*3+1+1+1]; // n???ゃ??????3n+1罅?篁ヤ???膃?垩??罅???\0??罅?
74 snprintf( buf, sizeof(buf), "%d", i );
75 string s( buf );
76 return s;
77 }
78
79
80

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26