ACDK鍩轟簬C++鐨勬ā鍨嬶紙鍩烘湰綾誨瀷銆佹帴鍙c佸璞$被錛屾暟緇勶紝寮傚父錛屾灇涓懼拰鍛藉悕絀洪棿錛夌粍緇囦簡鑷繁鐨勭被鍨嬫ā鍨嬨?br>
1銆佸熀鏈ā鍨?br> 鍩烘湰綾誨瀷 Object瀵硅薄灝佽 浣嶆暟(bit)
bool Boolean 8
char Character 8
uc2char UnicodeCharacter 16
uc4char UnicodeCharacter 23
byte Byte 8
short Short 16
int Integer 32
jlong Long 64
float Float 32
double Double 64
2銆丒num綾誨瀷
浣跨敤C++鐨別num錛屽亣濡傞渶瑕佽冭檻ACDK鐨勫厓緙栬瘧錛岄渶瑕佷嬌鐢ㄥ畯錛欰CDK_DECL_ENUM錛岀敤鏉ユ彁渚涘厓淇℃伅銆傚姩鎬佸簱闇瑕佸鍑虹被鍨嬬殑鏃跺欙紝浣跨敤ACDK_DEF_LIB_ENUM銆備笉鐗墊壇鍒板厓淇℃伅鐨凟num綾誨瀷鍙互鍦ㄥ畾涔夌殑鏃跺欎嬌鐢╢oreign鍏抽敭瀛椼?br>
3銆佸璞$被鍨?br> 蹇呴』鐩存帴鎴栬呴棿鎺ヤ粠Object媧劇敓
// declare the R-type RLegalAcdkClass
// and the Array type LegalAcdkClassArray and RLegalAcdkClassArray
ACDK_DECL_CLASS(LegalAcdkClass);
// The class itself:
class LegalAcdkClass : extends acdk::lang::Object // extend the Object class


{
ACDK_WITH_METAINFO(LegalAcdkClass); // optional, for class information see Metainfo
private:
RString message;
public:
// constructor
LegalAcdkClass() : Object() , message("")

{
}
// a method
RString getMessage()

{
return message;
}
};
涓嶈兘澶氱戶鎵跨被錛屼絾鏄彲浠ユ彁渚涗竴縐嶆洿濂界殑鍔炴硶灝辨槸澶氱戶鎵挎帴鍙c?/p>
// declare the R-type RLegalAcdkClass
// and the Array type LegalAcdkClassArray and RLegalAcdkClassArray
ACDK_DECL_CLASS(LegalAcdkClass);
// The class itself:
class LegalAcdkClass : extends acdk::lang::Object // extend the Object class
, implements acdk::lang::Comparable // implements the interface


{
ACDK_WITH_METAINFO(LegalAcdkClass) // optional, for class information see Metainfo
private:
RString message;
public:
// implement the Comparable interface method
int compareTo(IN(RObject) other)

{
return getMessage()->compareTo(RLegalAcdkClass(other)->getMessage());
}

RString getMessage()
{ return message; }
};
Class淇℃伅
RStringBuffer sb1 = new StringBuffer("ACDK");
RStringBuffer sb2 = new StringBuffer("JAVA");
RClass cls1 = sb1->getClass();
RClass cls2 = sb2->getClass();
assert(cls1 == cls2); // always true
浣犲彲浠ュ畾涔変笉絎﹀悎acdk瑙勮寖鐨勭被鍨嬪凡緇忕粨鏋勭瓑錛屼絾鏄細澶卞幓acdk鎻愪緵鐨勪竴浜涚壒鎬с?/p>
ACDK鐨勫紓甯告崟鑾烽渶瑕佹敞鎰忥細
void foo()


{

try
{

} catch (acdk::io::RIOException ex)
{
// handle here type of IOException.

} catch (RThrowable ex)
{
// handle all other ACDK exceptions
}

/**//* DONT DO THAT
otherwise Nullpointer exception will not handled properly
} catch (
) {
// this are not ACDK exception
// for example std::exception, if you use STL
}
*/
}
鏂規硶鍙傛暟緙虹渷浼犻掓柟寮忔槸錛?br>a銆佸熀鏈被鍨?int,float,char,etc)鎸夊間紶閫?br>b銆乪num鎸夊?br>c銆佺被鍜屾帴鍙f寜寮曠敤浼犻?br>d銆佹暟緇勬寜寮曠敤浼犻?br>
鍙傛暟鐨刬n,out,inout
void foo(IN(RStringBuffer) buffer, int len)


{
//buffer = new StringBuffer(); // caller not be effected, RStringBuffer isn't changed
buffer->append("asdf"); // caller be effected.
len = 42; // caller not be effected
}

// is equivalent to
//void foo(RStringBuffer buffer, int len);
void use_foo()


{
RStringBuffer sb = new StringBuffer("");
RStringBuffer sbs = sb;
int value = 1000;
foo(sb, value);
//value == 1000 && sb == sbs
// sb->toString() == "ACDK"
}
in鍙傛暟紜繚瀵硅薄寮曠敤涓嶄細鍙樺寲錛涘彲浠ヤ紶閫掓爤瀵硅薄
void foo(OUT(RStringBuffer) buffer, OUT(int) len)


{
// buffer is unitialized here
buffer = new StringBuffer(1024);
// buffer is now initialed;
buffer->append("ACDK");
len = buffer->length();
}
RString use_foo()


{
RStringBuffer sb;
int len;
foo(sb, len);
System::out->println("Buffer is [" + sb->toString() + "] len = " + len);
return sb->toString();
}
浣跨敤out鍙傛暟錛屾寜鐓у紩鐢ㄤ紶鍙傦紝鍙互淇敼浼犲叆鍙傛暟錛屼絾鏄浜庤繘紼嬮棿涓嶅彲浠ヤ紶閫掓爤瀵硅薄銆?br>

]]>