C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[4759] Re:Re:RE: 안되는걸로 알고 있습니당. -> 되는 데요! -> 음...좀 틀린데요
thomamin [] 3366 읽음    2001-01-04 00:00
property의 선언은 다음과 같은 문법을 갖고 있죠

<property declaration> ::=
      __property <type> <id> [ <prop dim list> ] = "{" <prop attrib list> "}"
  <prop dim list> ::= "[" <type> [ <id> ] "]" [ <prop dim list> ]
  <prop attrib list> ::= <prop attrib> [ , <prop attrib list> ]
  <prop attrib> ::=     read = <data/function id>
  <prop attrib> ::=     write = <data/function id>
  <prop attrib> ::=     stored = <data/function id>
  <prop attrib> ::=     stored = <boolean constant>
  <prop attrib> ::=     default = <constant>
  <prop attrib> ::=     nodefault
  <prop attrib> ::=     index = <const int expression>

님께서 보신 예제는 위의 문법 중에서 마지막에 나오는 index specifier를 이용한 예로서
질문하신 것과는 차이가 있습니다. 즉 예제의 function에 나오는 int Index는 index specifier를
사용할 때 쓰는 것으로 예제에 나오는 것 처럼  property 선언 때 1,2,3등 constant값을 주어야만 하는 것입니다.


새해 복 많이 받으시구요.  문제 빨리 해결하시길 바랍니다.
저도 좀 있다가 님처럼 XML dll import해야될거 같은 생각이 드는데 모르는거 있음 물어보께여



//-------------------------------------------------------------------------------------
이강건 님이 쓰신 글 :
: thomamin 님이 쓰신 글 :
: : read에 줄 수 있는건 같은 type의 method나 field인데요 method는 C++builder help에 보면 parameter가 없는 function만 가능하다고 돼있습니다.
: : 참고로 write에 쓰는 method는 변수 한개인 것만 되는거 아시죠?
: :
: : for more information ->  help에서 read입력하고 찾아보세요
: :
: :
: :
: :
: :
: :
: : 이강건 님이 쓰신 글 :
: : : 안녕하세요. 이강건입니다.
: : :
: : : BCB에서 XML을 사용하려고 합니다.
: : : 델파이에서처럼 Project메뉴의 Import Type Library를 이용하여 MSXML.DLL을 임포트하는데, 컴파일시 에러가 발생합니다.
: : :
: : : 자세히 보니, 프로퍼티에서 사용하는 함수가 인자를 받더군요.
: : : 즉, 다음과 같이 프로퍼티가 선언되어 있고...
: : :
: : :   __property Msxml_tlb::IXMLElement2Ptr ={ read=Get_root };
: : :   __property long readyState={ read=Get_readyState };
: : :   __property BSTR version={ read=Get_version };
: : :   __property BSTR doctype={ read=Get_doctype };
: : :
: : :
: : : 해당 함수가 아래처럼 정의되어 있습니다.
: : :
: : :   Msxml_tlb::IXMLElement2Ptr __fastcall Get_root(Msxml_tlb::IXMLElement2Ptr* p)
: : :   {
: : :     return GetDefaultInterface()->get_root(p/*[out,retval]*/);
: : :   }
: : :
: : :   long __fastcall Get_readyState(long* pl/*[out,retval]*/)
: : :   {
: : :     return GetDefaultInterface()->get_readyState(pl/*[out,retval]*/);
: : :   }
: : :
: : : 그러니까 인자를 받는 함수들이지요.
: : :
: : : 프로퍼티의 Get메쏘드로 오는 함수가 인자를 가질 수 있습니까?
: : :
: : :
: : : 위를 컴파일할때 나는 에러는 다음과 같습니다.
: : :
: : :   __property Msxml_tlb::IXMLElement2Ptr ={ read=Get_root };
: : :         -> Declaration terminated incorrectly.
: : :
: : :   __property long readyState={ read=Get_readyState };
: : :   __property BSTR version={ read=Get_version };
: : :   __property BSTR doctype={ read=Get_doctype };
: : :         -> Parameter mismatch in read access specifier of property readyState(...)
: : :
: : : 그럼 도움을 기다리겠습니다.
: : : 이만...
: : : 꾸벅~
: : :
:
: 안녕하세요. 이강건입니다.
:
: 먼저, 답변주셔서 감사합니다.
:
: 말씀대로 C++ Builder Help에서 Read를 찾아보면 example에 다음(밑에 영문 헬프를 그대로 옮겼습니다. 예제가 있습니다.)과 같이 나와있습니다.
: (참고로 저는 C++ Builder 5 enterprise버전입니다.)
:
: 예제를 보시면 read시에는 index라는 파라미터 하나를 받고 있고, write시에는 index와 value라는 두개의 파라미터를 받고 있습니다.
:
: 그러므로 님의 답변과는 차이가 있다고 보여집니다.
:
: 음, 이 예제를 보면 제가 질문 올린 내용이 컴파일이 되야 하는데 왜 안될까요?
:
: 그럼 다음 답변 및 도움을 기다리겠습니다.
:
: ----------------------------------------------
: Example: Property access methods
:
: Here is a class that declares three properties using the index specifier, which allows all three properties to have the same read and write access methods:
:
: class PACKAGE TSampleCalendar : public TCustomGrid
:
: {
: private:
:   int __fastcall GetDateElement(int Index);    // note Index parameter
:   void __fastcall SetDateElement(int Index, int Value);
: public:
:   __property int Day = {read=GetDateElement, write=SetDateElement, index=3, nodefault};
:   __property int Month = {read=GetDateElement, write=SetDateElement, index=2, nodefault};
:   __property int Year = {read=GetDateElement, write=SetDateElement, index=1, nodefault};
: };
:
: Because each element of the date (day, month, and year) is an int, and because setting each requires encoding the date when set, the code avoids duplication by sharing the read and write methods for all three properties. You need only one method to read a date element, and another to write the date element.
: Here is the read method that obtains the date element:
:
: int __fastcall TSampleCalendar::GetDateElement(int Index)
:
: {
:   unsigned short AYear, AMonth, ADay;
:   int result;
:   FDate.DecodeDate(&AYear, &AMonth, &Aday); // break date into elements
:   switch (Index)
:   {
:     case 1: result = AYear;  break;
:     case 2: result = AMonth; break;
:     case 3: result = ADay;   break;
:     default: result = -1;
:   }
:   return result;
: }
:
: This is the write method that sets the appropriate date element:
:
: void __fastcall TSampleCalendar::SetDateElement(int Index, int Value)
:
: {
:   unsigned short AYear, AMonth, ADay;
:   if (Value > 0) // all elements must be positive
:   {
:     FDate.DecodeDate(&AYear, &AMonth, &ADay); // get date elements
:     switch (Index)
:     {
:       case 1: AYear = Value;  break;
:       case 2: AMonth = Value; break;
:       case 3: ADay = Value;   break;
:       default: return;
:     }
:  }
:  FDate = TDateTime(AYear, AMonth, ADay); // encode the modified date
:  Refresh();// update the visible calendar
: }

+ -

관련 글 리스트
4743 MSXML.DLL을 Import Typelibrary 할 경우... 이강건 4363 2001/01/03
4755     RE: 안되는걸로 알고 있습니당. thomamin 3360 2001/01/04
4757         Re:RE: 안되는걸로 알고 있습니당. -> 되는 데요! 이강건 3372 2001/01/04
4759             Re:Re:RE: 안되는걸로 알고 있습니당. -> 되는 데요! -> 음...좀 틀린데요 thomamin 3366 2001/01/04
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.