LocalConfig.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef LocalConfig_H
  14. #define LocalConfig_H
  15. #include <ndb_global.h>
  16. #include <NdbOut.hpp>
  17. //****************************************************************************
  18. // Description: The class LocalConfig corresponds to the information possible
  19. // to give in the local configuration file.
  20. //*****************************************************************************
  21. enum MgmtSrvrId_Type {
  22.   MgmId_TCP  = 0,
  23.   MgmId_File = 1
  24. };
  25. struct MgmtSrvrId {
  26.   MgmtSrvrId_Type type;
  27.   BaseString name;
  28.   unsigned int port;
  29. };
  30. struct LocalConfig {
  31.   int _ownNodeId;
  32.   Vector<MgmtSrvrId> ids;
  33.   
  34.   int error_line;
  35.   char error_msg[256];
  36.   LocalConfig();
  37.   ~LocalConfig();
  38.   bool init(const char *connectString = 0,
  39.     const char *fileName = 0);
  40.   void printError() const;
  41.   void printUsage() const;
  42.   void setError(int lineNumber, const char * _msg);
  43.   bool readConnectString(const char *, const char *info);
  44.   bool readFile(const char * file, bool &fopenError);
  45.   bool parseLine(char * line, int lineNumber);
  46.   
  47.   bool parseNodeId(const char *buf);
  48.   bool parseHostName(const char *buf);
  49.   bool parseFileName(const char *buf);
  50.   bool parseString(const char *buf, BaseString &err);
  51.   char * makeConnectString(char *buf, int sz);
  52. };
  53. #endif // LocalConfig_H