/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/include/BDSMySQLWrapper.hh

00001 /* * BDSIM code.    Version 1.0
00002    * Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    * Last modified 24.7.2002
00004    * Copyright (c) 2002 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 
00006 
00007    Author of this code: John C. Carter, Royal Holloway, Univ. of London.
00008    Last modified 12.10.2005
00009 */
00010 
00011 
00012 #ifndef BDSMySQLWrapper_h
00013 #define BDSMySQLWrapper_h 1
00014 
00015 #include "BDSAcceleratorComponent.hh"
00016 #include "BDSMySQLTable.hh"
00017 #include <fstream>
00018 #include <vector>
00019 #include <string>
00020 
00021 #define  _NEXT if(!NextToken()) return;
00022 #define  _NEXTINPUT if(!NextInputToken()) return;
00023 #define CMD_CREATE   "CREATE"
00024 #define CMD_TABLE    "TABLE"
00025 #define CMD_INSERT   "INSERT"
00026 #define CMD_INTO     "INTO"
00027 #define CMD_VALUES   "VALUES"
00028 #define CMD_DROP     "DROP"
00029 #define CMD_DATABASE "DATABASE"
00030 #define CMD_USE      "USE"
00031 #define CMD_IF       "IF"
00032 #define CMD_EXISTS   "EXISTS"
00033 
00034 class BDSMySQLWrapper 
00035 {
00036 public:
00037   BDSMySQLWrapper (const G4String& SQLFileName);
00038   ~BDSMySQLWrapper();
00039   
00040   std::vector<BDSMySQLTable*> ConstructTable();
00041 
00042   G4int GetComponentN() {return ComponentN;}
00043  
00044   std::vector<BDSMySQLTable*> table;
00045 
00046 protected:
00047   
00048 private:
00049   // Data Members for Class Attributes
00050 
00051   std::ifstream ifs;
00052   
00053   G4String CurrentTableName;
00054   G4String InsertTableName;
00055   G4int ComponentN;
00056 
00057   G4int tableN;
00058 
00059   void ReadLine();
00060   void RemoveCommentsFromLine(std::string& value);
00061   void RemoveQuotesFromLine(std::string& value);
00062   void RemoveWhitespace(std::string&);
00063   void RemoveWhitespace(G4String&);
00064   void TokenizeLine();
00065   std::vector<std::string> _tokens;
00066   std::vector<std::string>::iterator _tokens_iter;
00067 
00068   void BeginTokens();
00069   bool NextToken();
00070   bool NextInputToken();
00071   bool EndTokens();
00072   std::string Token();
00073   bool EndOfLine();
00074   bool EmptyToken();
00075   void ProceedToEndOfLine();
00076   G4int ParseComponent();
00077   //Methods for carrying out the various instructions:
00078   void Create();
00079   void CreateDatabase();
00080   void CreateTable();
00081   void Insert();
00082   void InsertInto();
00083   void Values();
00084 
00085   std::string _currentLine;
00086   bool _startOfFile;
00087 
00088 
00089 };
00090 
00091 #endif

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7