00001 /* 00002 * Name: filter.m4 00003 * 00004 * Description: 00005 * DOXYGEN Input file filter for DRAMA source files. 00006 * 00007 * This file must be complatible with both Solaris and GNU m4. All 00008 * unused macros are deleted and this comment must end up as a C/C++ 00009 * compatible comment which is not picked up by DOXYGEN. 00010 * 00011 * Synopsis: 00012 * DCF(func) => Produces a link to a DRAMA C source file func.html 00013 * in ../routines. 00014 * DDL(link,text) => Produce a link to ../link.html, specified link text. 00015 * 00016 * Language: m4 macro. 00017 * 00018 * Author: Tony Farrell, AAO. 00019 * 00020 * "@(#) $Id: ACMM:DramaHtml/filter.m4,v 3.24 03-Nov-2009 09:07:29+11 tjf $" 00021 * 00022 * History: 00023 * 10-Nov-2004 - TJF - Original Version. 00024 */ 00025 00026 00027 00028 #ifndef ARGINC 00029 #define ARGINC 00030 /* 00031 * @(#) $Id: ACMM:sds/arg.h,v 3.48 02-Nov-2009 14:50:58+11 tjf $ 00032 */ 00033 /* 00034 * This file now uses DOXYGEN comments to generate the C++ web pages. 00035 * m4 macros of the form @htmlonly <a href="../routines/function.html">function()</a>@endhtmlonly are used in the comments 00036 * to refer to DRAMA C function documention (see DramaHtml/Makefile, 00037 * DramaHtml/doxygen.config and DramaHtml/filter.m4 for detials) 00038 */ 00039 00040 #ifdef __cplusplus 00041 00042 /* 00043 * If under C++ and this is allowed, then we can add functions which 00044 * require the C++ Standard Library (say under GCC 2.95.2 or later). 00045 */ 00046 #ifdef DRAMA_ALLOW_CPP_STDLIB 00047 #include <string> 00048 #endif 00049 00050 extern "C" { 00051 00052 #endif 00053 00054 #include "arg_err.h" 00055 #include "status.h" 00056 00057 #define ARG_SDS -1 00058 #define ARG_STRING -2 00059 #define ARG_STRING2 -3 00060 00061 /* 00062 * Is const acceptable on this machine. 00063 */ 00064 #if defined(__cplusplus) || defined(__STDC__) || defined (VAXC) 00065 # define ARGCONST const 00066 #else 00067 # define ARGCONST /* */ 00068 #endif 00069 00070 00071 /* 00072 * Under Windows, we may need to export or import the functions, depending 00073 * on if we are building the DLL or linking against it. 00074 */ 00075 #ifdef WIN32 00076 #ifdef DRAMA_DLL /* Am building DRAMA DLL */ 00077 #define ARGEXTERN __declspec(dllexport) 00078 #elif defined(DRAMA_STATIC) /* Building a static library */ 00079 #define ARGEXTERN extern 00080 #else /* Am building application with DLL */ 00081 #define ARGEXTERN __declspec(dllimport) 00082 #endif 00083 00084 #else 00085 #define ARGEXTERN extern 00086 #endif 00087 00088 /* 00089 * If defined, we are using the newer C++ overloads. 00090 */ 00091 #define ARG_NEWCPP_OVERLOADS 1 00092 00093 00094 ARGEXTERN void ArgNew(SdsIdType *id, StatusType * ARGCONST status); 00095 ARGEXTERN void ArgPutc(SdsIdType id, ARGCONST char *name, char value, 00096 StatusType * ARGCONST status); 00097 ARGEXTERN void ArgPuts(SdsIdType id, ARGCONST char *name, short value, 00098 StatusType * ARGCONST status); 00099 ARGEXTERN void ArgPutus(SdsIdType id, ARGCONST char *name, unsigned short value, 00100 StatusType * ARGCONST status); 00101 ARGEXTERN void ArgPuti(SdsIdType id, ARGCONST char *name, long value, 00102 StatusType * ARGCONST status); 00103 ARGEXTERN void ArgPuti64(SdsIdType id, ARGCONST char *name, INT64 value, 00104 StatusType * ARGCONST status); 00105 00106 ARGEXTERN void ArgPutu(SdsIdType id, ARGCONST char *name, unsigned long value, 00107 StatusType * ARGCONST status); 00108 00109 ARGEXTERN void ArgPutu64(SdsIdType id, ARGCONST char *name, UINT64 value, 00110 StatusType * ARGCONST status); 00111 00112 ARGEXTERN void ArgPutf(SdsIdType id, ARGCONST char *name, float value, 00113 StatusType * ARGCONST status); 00114 ARGEXTERN void ArgPutd(SdsIdType id, ARGCONST char *name, double value, 00115 StatusType * ARGCONST status); 00116 ARGEXTERN void ArgPutString(SdsIdType id, ARGCONST char *name, ARGCONST char *value, 00117 StatusType * ARGCONST status); 00118 ARGEXTERN void ArgGetc(SdsIdType id, ARGCONST char *name, char *value, 00119 StatusType * ARGCONST status); 00120 ARGEXTERN void ArgGets(SdsIdType id, ARGCONST char *name, short *value, 00121 StatusType * ARGCONST status); 00122 ARGEXTERN void ArgGetus(SdsIdType id, ARGCONST char *name, unsigned short *value, 00123 StatusType * ARGCONST status); 00124 ARGEXTERN void ArgGeti(SdsIdType id, ARGCONST char *name, long *value, 00125 StatusType * ARGCONST status); 00126 ARGEXTERN void ArgGeti64(SdsIdType id, ARGCONST char *name, INT64 *value, 00127 StatusType * ARGCONST status); 00128 00129 ARGEXTERN void ArgGetu(SdsIdType id, ARGCONST char *name, unsigned long *value, 00130 StatusType * ARGCONST status); 00131 ARGEXTERN void ArgGetu64(SdsIdType id, ARGCONST char *name, UINT64 *value, 00132 StatusType * ARGCONST status); 00133 00134 ARGEXTERN void ArgGetf(SdsIdType id, ARGCONST char *name, float *value, 00135 StatusType * ARGCONST status); 00136 ARGEXTERN void ArgGetd(SdsIdType id, ARGCONST char *name, double *value, 00137 StatusType * ARGCONST status); 00138 ARGEXTERN void ArgGetString(SdsIdType id, ARGCONST char *name, long len, char *value, 00139 StatusType * ARGCONST status); 00140 ARGEXTERN void ArgDelete(SdsIdType id, StatusType * ARGCONST status); 00141 00142 00143 ARGEXTERN void ArgCvt (ARGCONST void * SrcAddr, SdsCodeType SrcType, SdsCodeType DstType, 00144 void * DstAddr, unsigned long int DstLen , 00145 StatusType * ARGCONST status); 00146 ARGEXTERN void ArgLook (char *SrcAddr, int USFlag, int MinFlag, SdsCodeType *DstType, 00147 StatusType * ARGCONST status); 00148 00149 00150 ARGEXTERN void ArgToString (SdsIdType id,int maxlen,int *length,char *string, 00151 StatusType * ARGCONST status); 00152 00153 typedef void (*ArgListFuncType)( 00154 void *client_data, 00155 ARGCONST char *line, 00156 StatusType * status); 00157 ARGEXTERN void ArgSdsList(SdsIdType id, unsigned buflen, char *buffer, 00158 ArgListFuncType func, void * client_data, 00159 StatusType * ARGCONST status); 00160 00161 00162 ARGEXTERN void ArgFind(SdsIdType parent_id, ARGCONST char *name, 00163 SdsIdType *id, 00164 StatusType * ARGCONST status); 00165 00166 ARGEXTERN void ArgCheckItem(SdsIdType id, 00167 SdsCodeType code, long ndims, 00168 long * ARGCONST dims, 00169 StatusType * ARGCONST status); 00170 00171 #ifdef __cplusplus 00172 } /* extern "C" */ 00173 00174 00175 /* 00176 * C++ only section. 00177 * 00178 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00179 * 00180 * Here is the a C++ interface to ARG. No object modifications required since 00181 * all code is inline. 00182 */ 00200 class Arg : public SdsId { 00201 private: 00202 /* Assignment and Copy operators, made private to avoid misuse, but 00203 this is done in SdsId so would have been prohibited anyway 00204 */ 00205 Arg& operator=(const Arg&); /* Assignment */ 00206 Arg(const Arg&); /* Copy */ 00207 public: 00231 Arg (const SdsIdType item=0, const bool free=false, 00232 const bool del = false, const bool readfree = false) : 00233 SdsId(item,free,del,readfree) { 00234 }; 00251 Arg (bool flag, StatusType * const status, 00252 const char * const name = "ArgStructure") : 00253 SdsId(name, SDS_STRUCT,status) { 00254 flag = false; /* to shut up compiler */ 00255 } 00256 00269 void New (StatusType * const status, 00270 const char * const name = "ArgStructure") { 00271 /* 00272 * We create the new item and then us SdsId::ShallowCopy to 00273 * copy it into this object. 00274 */ 00275 Arg tid(true,status, name); 00276 ShallowCopy(tid,true); 00277 }; 00278 00293 Arg(const SdsId& source, const char * const name, 00294 StatusType * const status) : 00295 SdsId(0,false,false,false) { 00296 /* 00297 * This is confusing since what we really want is to do is SdsFind 00298 * but we want the ErsRep reporting facilities of ArgFind, so we 00299 * must create this item as a null item, call ArgFind using the 00300 * arguments and then use ShallowCopy to copy the SdsIdType to this 00301 * item 00302 */ 00303 SdsIdType tid=0; 00304 ArgFind(source,name,&tid,status); 00305 ShallowCopy(tid,true,false,false); 00306 } 00307 00322 void ToString(int maxlen, int *length, char *string, 00323 StatusType * const status) 00324 { 00325 ArgToString(*this,maxlen,length,string,status); 00326 } 00355 void CheckItem(SdsCodeType code, 00356 StatusType *status, 00357 long ndims=-1, 00358 long * dims=0) 00359 { 00360 ArgCheckItem(*this, code, ndims, dims, status); 00361 } 00362 00363 00364 # ifndef CPP_NOBOOL 00365 00383 void Put (const char *name, bool value, StatusType * const status) { 00384 unsigned short v = (int)value; 00385 ArgPutus(*this,name,v,status); 00386 }; 00387 # endif 00388 00402 void Put (const char *name, char value, StatusType * const status) { 00403 ArgPutc(*this,name,value,status); 00404 }; 00419 void Put (const char *name, short value, StatusType * const status) { 00420 ArgPuts(*this,name,value,status); 00421 }; 00437 void Put (const char *name, unsigned short value, 00438 StatusType * const status) { 00439 ArgPutus(*this,name,value,status); 00440 }; 00441 00457 void Put (const char *name, INT32 value, StatusType * const status) { 00458 ArgPuti(*this,name,value,status); 00459 }; 00460 00476 void Put (const char *name, UINT32 value, StatusType * const status) { 00477 ArgPutu(*this,name,value,status); 00478 }; 00494 void Put (const char *name, INT64 value, StatusType * const status) { 00495 ArgPuti64(*this,name,value,status); 00496 }; 00512 void Put (const char *name, UINT64 value, StatusType * const status) { 00513 ArgPutu64(*this,name,value,status); 00514 }; 00530 void Put (const char *name, float value, StatusType * const status) { 00531 ArgPutf(*this,name,value,status); 00532 }; 00548 void Put (const char *name, double value, StatusType * const status) { 00549 ArgPutd(*this,name,value,status); 00550 }; 00568 void Put (const char *name, const char *value, StatusType * const status) { 00569 ArgPutString(*this,name,value,status); 00570 }; 00571 00572 00573 # ifndef CPP_NOBOOL 00574 00589 void Get (const char *name, bool * value, 00590 StatusType * const status)const { 00591 unsigned short v; 00592 ArgGetus(*this,name,&v,status); 00593 *value = v ? true : false; 00594 } 00595 # endif 00596 00609 void Get (const char *name, char * value, StatusType * const status)const { 00610 ArgGetc(*this,name,value,status); 00611 } 00624 void Get (const char *name, short * value, StatusType * const status)const { 00625 ArgGets(*this,name,value,status); 00626 } 00640 void Get (const char *name, unsigned short * value, 00641 StatusType * const status) const { 00642 ArgGetus(*this,name,value,status); 00643 } 00657 void Get (const char *name, INT32 * value, StatusType * const status ) const{ 00658 long v; /* Since ArgGeti uses long */ 00659 ArgGeti(*this,name,&v,status); 00660 *value = v; 00661 } 00675 void Get (const char *name, UINT32 * value, 00676 StatusType * const status)const { 00677 unsigned long v; /* Since ArgGetu always uses long */ 00678 ArgGetu(*this,name,&v,status); 00679 *value = v; 00680 } 00694 void Get (const char *name, INT64 * value, StatusType * const status) const{ 00695 ArgGeti64(*this,name,value,status); 00696 } 00710 void Get (const char *name, UINT64 * value, StatusType * const status)const{ 00711 ArgGetu64(*this,name,value,status); 00712 } 00713 00726 void Get (const char *name, float * value, StatusType * const status) const{ 00727 ArgGetf(*this,name,value,status); 00728 } 00741 void Get (const char *name, double * value, StatusType * const status)const { 00742 ArgGetd(*this,name,value,status); 00743 } 00757 void Get (const char *name, long len, char * value, 00758 StatusType * const status) const{ 00759 ArgGetString(*this,name,len,value,status); 00760 } 00779 static void List(const SdsId & id, unsigned buflen, char *buffer, 00780 ArgListFuncType func, void * client_data, 00781 StatusType * ARGCONST status) { 00782 ArgSdsList(id,buflen,buffer,func,client_data,status); 00783 } 00784 00785 /* 00786 * 00787 * Arg hids some Sds functions, so we redeclare them here. 00788 */ 00795 void List(StatusType * const status) const { 00796 SdsList(*this,status); 00797 } 00820 void Get(const unsigned long length, 00821 void * const data, 00822 StatusType * const status, 00823 unsigned long *actlen = 0, 00824 const unsigned long offset=0) const { 00825 SdsId::Get(length,data,status,actlen,offset); 00826 } 00847 void Put(const unsigned long length, 00848 void * const data, 00849 StatusType * const status, 00850 const unsigned long offset=0) 00851 { 00852 SdsId::Put(length,data,status,offset); 00853 } 00854 00855 00856 #ifdef DRAMA_ALLOW_CPP_STDLIB 00857 /* 00858 * If DRAMA is allowed to use the C++ Standard Template library, then 00859 * we add these functions to arg. All of these are about using 00860 * std::string instead of char[], and the only complicatef one 00861 * is the Get function which gets the value as a string. 00862 * 00863 */ 00864 00880 Arg(const SdsId &source, 00881 const std::string &name, 00882 StatusType *const status) : 00883 SdsId(0,false,false,false) { 00884 SdsIdType tid=0; 00885 ArgFind(source,name.c_str(),&tid,status); 00886 ShallowCopy(tid,true,false,false); 00887 } 00888 00909 void Put (const std::string &name, bool value, StatusType * const status) { 00910 unsigned short v = (int)value; 00911 ArgPutus(*this,name.c_str(),v,status); 00912 }; 00929 void Put (const std::string &name, char value, StatusType * const status) { 00930 ArgPutc(*this,name.c_str(),value,status); 00931 }; 00948 void Put (const std::string &name,short value, StatusType * const status) { 00949 ArgPuts(*this,name.c_str(),value,status); 00950 }; 00968 void Put (const std::string &name, unsigned short value, 00969 StatusType * const status) { 00970 ArgPutus(*this,name.c_str(),value,status); 00971 }; 00989 void Put (const std::string &name, INT32 value, 00990 StatusType * const status) { 00991 ArgPuti(*this,name.c_str(),value,status); 00992 }; 01010 void Put (const std::string &name, UINT32 value, 01011 StatusType * const status) { 01012 ArgPutu(*this,name.c_str(),value,status); 01013 }; 01014 01032 void Put (const std::string &name, INT64 value, StatusType * const status) { 01033 ArgPuti64(*this,name.c_str(),value,status); 01034 }; 01052 void Put (const std::string &name, UINT64 value, StatusType * const status) { 01053 ArgPutu64(*this,name.c_str(),value,status); 01054 }; 01072 void Put (const std::string &name, float value, StatusType * const status) { 01073 ArgPutf(*this,name.c_str(),value,status); 01074 }; 01092 void Put (const std::string &name, double value, StatusType * const status) { 01093 ArgPutd(*this,name.c_str(),value,status); 01094 }; 01113 void Put(const char *name, 01114 const std::string &value, 01115 StatusType *status) { 01116 ArgPutString(*this, name, value.c_str(), status); 01117 } 01136 void Put(const std::string &name, 01137 const std::string &value, 01138 StatusType *status) { 01139 Put(name.c_str(), value, status); 01140 } 01158 void Get (const std::string &name, bool * value, 01159 StatusType * const status) const{ 01160 unsigned short v; 01161 ArgGetus(*this,name.c_str(),&v,status); 01162 *value = v ? true : false; 01163 } 01178 void Get (const std::string &name, char * value, StatusType * const status) const { 01179 ArgGetc(*this,name.c_str(),value,status); 01180 } 01195 void Get (const std::string &name, short * value, StatusType * const status) const { 01196 ArgGets(*this,name.c_str(),value,status); 01197 } 01213 void Get (const std::string &name, unsigned short * value, 01214 StatusType * const status) const{ 01215 ArgGetus(*this,name.c_str(),value,status); 01216 } 01232 void Get (const std::string &name, INT32 * value, 01233 StatusType * const status) const { 01234 Get(name.c_str(), value, status); 01235 } 01251 void Get (const std::string &name, UINT32 * value, 01252 StatusType * const status) const{ 01253 Get(name.c_str(), value, status); 01254 } 01270 void Get (const std::string &name, INT64 * value, StatusType * const status) const { 01271 ArgGeti64(*this,name.c_str(),value,status); 01272 } 01287 void Get (const std::string &name, UINT64 * value, StatusType * const status) const { 01288 ArgGetu64(*this,name.c_str(),value,status); 01289 } 01304 void Get (const std::string &name, float * value, StatusType * const status) const { 01305 ArgGetf(*this,name.c_str(),value,status); 01306 } 01321 void Get (const std::string &name, double * value, StatusType * const status) const { 01322 ArgGetd(*this,name.c_str(),value,status); 01323 } 01345 void Get(const char *name, 01346 std::string *value, 01347 StatusType *status, 01348 int buflen = 100) const { 01349 01350 /* Find the item we are interested in */ 01351 Arg ItemId(*this, name, status); 01352 if (*status != STATUS__OK) return; 01353 01354 char tname[SDS_C_NAMELEN]; 01355 SdsCodeType code; 01356 long ndims; 01357 unsigned long dims[SDS_C_MAXARRAYDIMS]; 01358 01359 /* Get details on this item */ 01360 ItemId.Info(tname, &code, &ndims, dims, status); 01361 if (*status != STATUS__OK) return; 01362 01363 if ((code == SDS_CHAR)&&(ndims == 1)) 01364 { 01365 /* Character array. Ensure we have sufficent space */ 01366 buflen = dims[0] + 1; 01367 } 01368 char *buffer; 01369 buffer = new char[buflen]; 01370 if (buffer == 0) 01371 { 01372 *status = ARG__MALLOCERR; 01373 return; 01374 } 01375 ArgGetString(*this, name, buflen, buffer, status); 01376 if (*status == STATUS__OK) 01377 *value = buffer; 01378 delete buffer; 01379 01380 } 01381 01382 /* 01383 * Interface to the above were the name string is a std::string. 01384 */ 01406 void Get(const std::string &name, 01407 std::string *value, 01408 StatusType *status, 01409 int buflen = 100) const { 01410 Get(name.c_str(), value, status, buflen); 01411 } 01412 #endif 01413 01414 }; /* class */ 01415 01416 01417 #endif 01418 01419 #endif 01420
Click here for the DRAMA home page and here for the AAO home page.
For more information, contact tjf@aaoepp.aao.gov.au Generated on Tue Nov 3 09:09:56 2009 for AAO DRAMA C++ Interfaces by
1.2.18