E D R , A S I H C RSS

Civa Project

μ£Όμš” μžλ°” APIλΌ C++ μ½”λ“œλ‘œ 바꿔보기.

civa.CivaDef

~cpp 
#ifndef CIVA_CIVADEF_INCLUDED
#define CIVA_CIVADEF_INCLUDED
#include <boost/smart_ptr.hpp>

namespace civa { namespace io {
using boost::shared_ptr;

class Serializable;
typedef shared_ptr<Serializable> Serializable_Handle;

}} // namespace civa::io

namespace civa { namespace lang {
using boost::shared_ptr;

template<typename ElementType> class Array;
//#define Array_Handle(ElementType) boost::shared_ptr< civa::lang::Array<ElementType> >
//template<typename ElementType> typedef shared_ptr< Array<ElementType> > Array_Handle;
typedef shared_ptr< Array<char> > charArray_Handle;

class CharSequence;
typedef shared_ptr<CharSequence> CharSequence_Handle;

class Comparable;
typedef shared_ptr<Comparable> Comparable_Handle;

class Object;
typedef shared_ptr<Object> Object_Handle;

class String;
typedef shared_ptr<String> String_Handle;

}} // namespace civa::lang
#endif // CIVA_CIVADEF_INCLUDED

뢄석 & μž‘λ‹΄

  • ν΄λž˜μŠ€λ“€μ΄ μ„œλ‘œ λ§žλ¬Όλ €μ„œ κ²°κ΅­ λ”°λ‘œ 빼게 λ˜μ—ˆκ΅°.
  • νŒŒλΌλ©”ν„°λΌμ΄μ¦ˆ typedef 은 컴파일이 μ•ˆλ˜λ„€.. 으으 Array 쓸땐 길게 λ‹€ μ¨μ€˜μ•Όν•˜λ‚˜..
  • λ§€ν¬λ‘œλŠ” μ“°κΈ° 싫은데.

civa.io.Serializable

~cpp 
#ifndef CIVA_IO_SERIALIZABLE_INCLUDED
#define CIVA_IO_SERIALIZABLE_INCLUDED
#include "../lang/Object.h"

namespace civa { namespace io {

class Serializable {
};

}} // namespace civa::io
#endif // CIVA_IO_SERIALIZABLE_INCLUDED

뢄석 & μž‘λ‹΄

  • μΈμŠ€ν„΄μŠ€ 생성 λͺ»ν•˜κ²Œ λ§‰μ•„μ€˜μ•Ό ν•˜λ‚˜.

civa.lang.Array

~cpp 
#ifndef CIVA_LANG_ARRAY_INCLUDED
#define CIVA_LANG_ARRAY_INCLUDED
#include "Object.h"

namespace civa { namespace lang {

template<typename ElementType>
class Array : public Object {
  private:
	ElementType* values;
	int length;

  public:
	Array(int length) throw() : length(length) {
		// λ°”μš΄λ“œ 체크.
		values = new ElementType[length];
	}

	Array(ElementType newValues[]) {
		// λ°°μ—΄μ˜ 크기가 이게 λ§žλ‚˜...
		length = sizeof(newValues) / sizeof(ElementType);
		values = new ElementType[length];
		for (index = 0; index < length; index++) {
			values[index] = newValuse[index];
		}
	}

	ElementType operator[] (int index) throw() {
		// λ°”μš΄λ“œ 체크.
		return values[index];
	}

	const ElementType operator[] (int index) const throw() {
		// λ°”μš΄λ“œ 체크.
		return values[index];
	}

	size_t getLength() {
		return length;
	}

  public:
	~Array() {
		delete[] values;
	}
};


}} // namespace civa::lang
#endif // CIVA_LANG_ARRAY_INCLUDED

뢄석 & μž‘λ‹΄

  • λ°”μš΄λ“œ μ²΄ν¬ν•΄μ„œ μ΅μ…‰μ…˜ λ˜μ§€λŠ”κ±° ν•΄μ•Όν•˜κ³ ,
  • λ°°μ—΄μ˜ 크기 μ•Œμ•„λ‚΄λŠ” 법 쑰사.

civa.lang.CharSequence

~cpp 
#ifndef CIVA_LANG_CHARSEQUENCE_INCLUDED
#define CIVA_LANG_CHARSEQUENCET_INCLUDED
#include "Object.h"

namespace civa { namespace lang {
class CharSequence {
  public:
	virtual int length() = NULL;
	virtual char charAt(int index) = NULL;
	virtual CharSequence_Handle subSequence(int start, int end) = NULL;
	virtual String_Handle toString() = NULL;
};


}} // namespace civa::lang
#endif // CIVA_LANG_CHARSEQUENCET_INCLUDED

뢄석 & μž‘λ‹΄

  • μΆ”μƒν΄λž˜μŠ€λ‹ˆ μΈμŠ€ν„΄μŠ€λŠ” 생성 μ•ˆλ˜κ² κ΅°.

civa.lang.Comparable

~cpp 
#ifndef CIVA_LANG_COMPARABLE_INCLUDED
#define CIVA_LANG_COMPARABLE_INCLUDED
#include "Object.h"

namespace civa { namespace lang {
class Comparable {
  public:
	virtual int compareTo(Object o) = NULL;
};


}} // namespace civa::lang
#endif // CIVA_LANG_COMPARABLE_INCLUDED

뢄석 & μž‘λ‹΄


civa.lang.Object

~cpp 
#ifndef CIVA_LANG_OBJECT_INCLUDED
#define CIVA_LANG_OBJECT_INCLUDED
#include "../CivaDef.h"

namespace civa { namespace lang {

class Object {
  public:
	void getClass() {/*μ°¨ν›„ μΆ”κ°€ Class getClass()*/}

	virtual int getHashCode() {
		return reinterpret_cast<int>(this);
	}

	virtual bool equals(Object_Handle obj) {
		return (this == obj.get());
	}

	virtual String_Handle toString() {
		/*μ°¨ν›„ μΆ”κ°€*/
		//return getClass().getName() + "@" + Integer.toHexString(hashCode());
	}

	void notify() {/*μ°¨ν›„ μΆ”κ°€*/}

	void notifyAll() {/*μ°¨ν›„ μΆ”κ°€*/}

	void wait(long timeout) throw() {/*μ°¨ν›„ μΆ”κ°€*/} //InterruptedException

	void wait(long timeout, int nanos) throw() { //InterruptedException
		if (timeout < 0) {
			throw ;//new IllegalArgumentException("timeout value is negative");
		}

		if (nanos < 0 || nanos > 999999) {
			throw ;//new IllegalArgumentException("nanosecond timeout value out of range");
		}

		if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
			timeout++;
		}

		wait(timeout);
	}

	void wait() throw() { //InterruptedException
		wait(0);
	}

  protected:
	virtual Object_Handle clone() throw() {
		throw ; //CloneNotSupportedException
		//으음. 클둠에이블 μΈν„°νŽ˜μ΄μŠ€ κ΅¬ν˜„μ—¬λΆ€λΌ μ–΄λ–»κ²Œ νŒλ‹¨ν•˜μ§€ -_-;;
		return Object_Handle(new Object(*this));
	}

	virtual void finalize() throw() {/*아무것도 μ•ˆν•¨*/ } //Throwable

  public:
	virtual ~Object() {}

};


}} // namespace civa::lang
#endif // CIVA_LANG_OBJECT_INCLUDED

뢄석 & μž‘λ‹΄

  • 일단 μ‹œμž‘... λ©€ν‹°μ“°λ ˆλ“œ κ΄€λ ¨ λ©”μ†Œλ“œμ™€ ν΄λž˜μŠ€λŠ” λͺ»ν•  λ“. κ³Όμ—° μ–΄λ””κΉŒμ§€ ν• λΌλ‚˜...
  • wait λ©”μ†Œλ“œμ˜ μ € 사기 λ‚˜λ…Έμ„Έμ»¨μ„ 보라. -_- μ™œ λ§Œλ“ κ±°μ§€, λΈλž˜μ˜ λŒ€λΉ„μΈκ°€...
  • C++ μ—μ„œ throw νƒ€μž…μ„ κ³ μ •μ‹œν‚¬ 수 μžˆλ‚˜...
  • λ©”μ†Œλ“œ μ˜€λ²„λΌμ΄λ”© κΈˆμ§€ μ‹œν‚¬ 수 μžˆλ‚˜..

civa.lang.String

~cpp 
#ifndef CIVA_LANG_STRING_INCLUDED
#define CIVA_LANG_STRING_INCLUDED
#include "Object.h"
#include "../io/Serializable.h"
#include "Comparable.h"
#include "CharSequence.h"
#include "Array.h"

namespace civa { namespace lang {

class String
: public Object, civa::io::Serializable, Comparable, CharSequence {
  private:
	/** The value is used for character storage. */
	charArray_Handle value;

	/** The offset is the first index of the storage that is used. */
	int offset;

	/** The count is the number of characters in the String. */
	int count;

	/** Cache the hash code for the string */
	int hash;

  public:
	String() : hash(0) {
		value = charArray_Handle(new Array<char>(0));
	}
};

}} // namespace civa::lang
#endif // CIVA_LANG_STRING_INCLUDED

뢄석 & μž‘λ‹΄


civa.lang.

뢄석 & μž‘λ‹΄

WIPI μ—μ„œ ATOC λΌ μ§€κΈˆ λ„κ°€ ν•˜λŠ”κ²ƒμ²˜λŸΌ μˆ˜ν–‰ν•œλ‹€λ”κ΅¬λ§Œ --;; .. --neocoin

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:53
Processing time 0.0149 sec