Drizzled Public API Documentation

systab_util_ms.h

00001 #pragma once
00002 #ifndef __SYSTAB_UTIL_H__
00003 #define __SYSTAB_UTIL_H__
00004 /* Copyright (C) 2009 PrimeBase Technologies GmbH, Germany
00005  *
00006  * PrimeBase Media Stream for MySQL
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00021  *
00022  *  Created by Barry Leslie on 3/20/09.
00023  *
00024  */
00025 
00026 #include "cslib/CSLog.h"
00027 
00028 
00029 class SysTabRec: public CSRefStringBuffer { 
00030   void logError(const char *text = NULL);
00031 
00032   bool findRecord();
00033 
00034   bool badRecord;
00035   
00036   uint32_t recordLength, start_of_record;
00037   
00038   public:
00039   const char *db_name, *file_name, *table_name;
00040   char *ptr, *end_of_record, *end_of_data;
00041 
00042   SysTabRec(const char *db_name_arg, const char *file_name_arg, const char *table_name_arg): 
00043     CSRefStringBuffer(64),
00044     badRecord(false),
00045     recordLength(0),
00046     start_of_record(0),
00047     db_name(db_name_arg),
00048     file_name(file_name_arg),
00049     table_name(table_name_arg),
00050     ptr(NULL),
00051     end_of_record(NULL),
00052     end_of_data(NULL)
00053   {
00054   }
00055   
00056   // Methods used to read records
00057   bool firstRecord();
00058   bool nextRecord();
00059   void resetRecord();
00060     
00061   uint8_t getInt1Field(); 
00062   uint32_t getInt4Field();  
00063   const char *getStringField();
00064     
00065   bool isValidRecord()
00066   {
00067     return ((ptr == end_of_record) && !badRecord);
00068   }
00069   
00070   // Methods used to write records
00071   void clear();
00072   void beginRecord();
00073   void endRecord();
00074   void setInt1Field(uint8_t val); 
00075   void setInt4Field(uint32_t val);  
00076   void setStringField(const char *val);
00077   void setStringField(const char *val, uint32_t len);
00078 
00079   
00080 };
00081 
00082 CSString *getPBMSPath(CSString *db_path);
00083 CSPath *getSysFile(CSString *db_path, const char *name, size_t min_size);
00084 
00085 #endif // __SYSTAB_UTIL_H__
00086