00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 #ifndef ACE_CAPABILITIES_H
00015 #define ACE_CAPABILITIES_H
00016 #include  "ace/pre.h"
00017 
00018 #include  "ace/config-all.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif 
00023 
00024 #include "ace/Null_Mutex.h"
00025 #include "ace/Hash_Map_Manager_T.h"
00026 #include "ace/Containers.h"
00027 #include "ace/SString.h"
00028 #include "ace/Functor_String.h"
00029 
00030 #if defined (ACE_IS_SPLITTING)
00031 # include "ace/OS_NS_ctype.h"
00032 #endif  
00033 
00034 
00035 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 class ACE_Export ACE_CapEntry
00048 {
00049 public:
00050 
00051    virtual ~ACE_CapEntry (void);
00052 
00053 protected:
00054 
00055   enum
00056   {
00057     ACE_INTCAP = 0,
00058     ACE_STRINGCAP = 1,
00059     ACE_BOOLCAP = 2
00060   };
00061 
00062   ACE_CapEntry (int captype);
00063 
00064 protected:
00065 
00066   int captype_;
00067 
00068 };
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 class ACE_Export ACE_IntCapEntry : public ACE_CapEntry
00079 {
00080 public:
00081   ACE_IntCapEntry (int val);
00082   int getval (void) const;
00083 
00084 protected:
00085   int val_;
00086 };
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 class ACE_Export ACE_StringCapEntry : public ACE_CapEntry
00097 {
00098 public:
00099   ACE_StringCapEntry (const ACE_TString &val);
00100   ACE_TString getval (void) const;
00101 
00102 protected:
00103   ACE_TString val_;
00104 };
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 class ACE_Export ACE_BoolCapEntry : public ACE_CapEntry
00115 {
00116 public:
00117   ACE_BoolCapEntry (int val);
00118   int getval (void) const;
00119 
00120 protected:
00121   int val_;
00122 };
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 class ACE_Export ACE_Capabilities
00140 {
00141 public:
00142 
00143   typedef  ACE_Hash_Map_Manager_Ex<ACE_TString, ACE_CapEntry *, ACE_Hash<ACE_TString>, ACE_Equal_To<ACE_TString>, ACE_Null_Mutex> CAPABILITIES_MAP;
00144 
00145 
00146   ACE_Capabilities (void);
00147 
00148 
00149   ~ACE_Capabilities(void);
00150 
00151 public:
00152 
00153 
00154   int getval (const ACE_TCHAR *ent, ACE_TString &val);
00155 
00156 
00157   int getval (const ACE_TCHAR *ent, int &val);
00158 
00159 
00160 
00161   int getent (const ACE_TCHAR *fname, const ACE_TCHAR *name);
00162 
00163 protected:
00164 
00165 
00166   const ACE_TCHAR *parse (const ACE_TCHAR *buf, int &cap);
00167 
00168 
00169   const ACE_TCHAR *parse (const ACE_TCHAR *buf, ACE_TString &cap);
00170 
00171 
00172   int fillent(const ACE_TCHAR *ent);
00173 
00174 
00175   int parseent (const ACE_TCHAR *name, ACE_TCHAR *line);
00176 
00177 
00178   int getline (FILE* fp,
00179                ACE_TString &line);
00180 
00181 
00182   int is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line);
00183 
00184 
00185   void resetcaps (void);
00186 
00187 private:
00188 
00189 
00190   CAPABILITIES_MAP caps_;
00191 
00192 };
00193 
00194 #if defined (ACE_IS_SPLITTING)
00195 int
00196 is_empty (const ACE_TCHAR *line)
00197 {
00198   while (*line && ACE_OS::ace_isspace (*line))
00199     ++line;
00200 
00201   return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#');
00202 }
00203 
00204 int
00205 is_line (const ACE_TCHAR *line)
00206 {
00207   while (*line && ACE_OS::ace_isspace (*line))
00208     ++line;
00209 
00210   return *line != ACE_TEXT ('\0');
00211 }
00212 #endif 
00213 
00214 ACE_END_VERSIONED_NAMESPACE_DECL
00215 
00216 #if defined (__ACE_INLINE__)
00217 #include "ace/Capabilities.inl"
00218 #endif 
00219 
00220 #include  "ace/post.h"
00221 #endif