|
yast2-core
|
00001 00010 // -*- c++ -*- 00011 00012 #ifndef AnyAgent_h 00013 #define AnyAgent_h 00014 00015 00016 #include <stdio.h> 00017 #include <sys/types.h> 00018 #include <stack> 00019 #include <scr/SCRAgent.h> 00020 00021 using std::stack; 00022 00023 00027 class AnyAgent : public SCRAgent 00028 { 00034 bool description_read; 00035 00042 time_t mtime; 00043 YCPValue cache; 00044 bool cchanged; 00045 YCPList alldata; 00046 bool achanged; 00047 00051 bool mReadOnly; 00052 00056 enum { MTYPE_NONE, MTYPE_FILE, MTYPE_PROG, MTYPE_LOCAL } mType; 00057 00061 YCPValue mName; 00062 00066 string mComment; 00067 bool isFillup; 00068 00072 YCPValue mSyntax; 00073 00077 YCPValue mHeader; 00078 00082 int line_number; 00083 00087 stack <string> tupleName; 00088 stack <YCPValue> tupleValue; 00089 bool tupleContinue; 00090 00091 public: 00092 00096 AnyAgent (); 00097 00101 ~AnyAgent (); 00102 00108 YCPValue Read (const YCPPath & path, const YCPValue & arg = YCPNull (), const YCPValue & opt = YCPNull ()); 00109 00113 YCPBoolean Write (const YCPPath & path, const YCPValue & value, 00114 const YCPValue & arg = YCPNull ()); 00115 00119 YCPList Dir (const YCPPath & path); 00120 00124 YCPValue otherCommand (const YCPTerm & term); 00125 00126 private: 00127 00128 YCPValue readValueByPath (const YCPValue & value, const YCPPath & path); 00129 YCPValue writeValueByPath (const YCPValue & current, const YCPPath & path, 00130 const YCPValue & value); 00131 00132 YCPValue findSyntax (const YCPValue & syntax, const YCPPath & path); 00133 00134 const char * get_line (FILE * fp); 00135 00136 // 00137 // Basic types (AnyAgentBasic) 00138 // 00139 00140 YCPValue parseIp4Number (char const *&lptr, bool optional); 00141 const string unparseIp4Number (const YCPValue & value); 00142 00143 YCPValue parseBoolean (char const *&lptr, bool optional); 00144 const string unparseBoolean (const YCPValue & value); 00145 00146 YCPValue parseNumber (char const *&lptr, bool optional); 00147 const string unparseNumber (const YCPValue & value); 00148 00149 YCPValue parseHexval (char const *&lptr, bool optional); 00150 const string unparseHexval (const YCPValue & value); 00151 00152 YCPValue parseString (char const *&lptr, const char *set, const char *stripped, 00153 bool optional); 00154 const string unparseString (const YCPValue & syntax, const YCPValue & stripped, 00155 const YCPValue & value); 00156 00157 YCPValue parseFloat (char const *&lptr, bool optional); 00158 const string unparseFloat (const YCPValue & value); 00159 00160 YCPValue parseHostname (char const *&lptr, bool optional); 00161 const string unparseHostname (const YCPValue & value); 00162 00163 YCPValue parseUsername (char const *&lptr, bool optional); 00164 const string unparseUsername (const YCPValue & value); 00165 00166 YCPValue parseVerbose (char const *&lptr, const char *match, bool optional); 00167 const string unparseVerbose (const YCPValue & value); 00168 00169 YCPValue parseSeparator (char const *&lptr, const char *match, bool optional); 00170 const string unparseSeparator (const YCPValue & match); 00171 00172 const char * getLine (void); 00173 const string putLine (const string s); 00174 00175 // 00176 // Complex types (AnyAgentComplex) 00177 // 00178 00179 YCPValue parseChoice (char const *&line, const YCPList & syntax, bool optional); 00180 const string unparseChoice (const YCPList & syntax, const YCPValue & value); 00181 00182 YCPValue parseSequence (char const *&line, const YCPList & syntax, bool optional); 00183 const string unparseSequence (const YCPList & syntax, const YCPValue & value); 00184 00185 YCPValue parseList (char const *&line, const YCPList & syntax, bool optional); 00186 const string unparseList (const YCPList & syntax, const YCPValue & value); 00187 00188 YCPValue parseTuple (char const *&line, const YCPList & syntax, bool optional); 00189 const string unparseTuple (const YCPList & syntax, const YCPValue & value); 00190 00191 YCPValue parseData (char const *&line, const YCPValue & syntax, bool optional); 00192 const string unparseData (const YCPValue & syntax, const YCPValue & value); 00193 00194 YCPValue validateCache (const YCPList & data, const YCPValue & arg = YCPNull ()); 00195 YCPValue readFile (const YCPValue & arg); 00196 const string writeFile (const YCPValue & arg); 00197 00198 string evalArg (const YCPValue & arg); 00199 00200 int lineNumber () const; 00201 00202 }; 00203 00204 00205 #endif // AnyAgent_h
1.7.3