WhirlyGlobe  1.2
A 3D interactive globe toolkit for iOS
/Users/sjg/iPhone/WhirlyGlobe/WhirlyGlobeSrc/WhirlyGlobeLib/include/sqlhelpers.h
00001 /*
00002  *  sqlhelpers.h
00003  *  SousVide
00004  *
00005  *  Created by Steve Gifford on 9/8/09.
00006  *  Copyright 2011 mousebird consulting
00007  *
00008  *  Licensed under the Apache License, Version 2.0 (the "License");
00009  *  you may not use this file except in compliance with the License.
00010  *  You may obtain a copy of the License at
00011  *  http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  *  Unless required by applicable law or agreed to in writing, software
00014  *  distributed under the License is distributed on an "AS IS" BASIS,
00015  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  *  See the License for the specific language governing permissions and
00017  *  limitations under the License.
00018  *
00019  */
00020 
00021 #include <Foundation/Foundation.h>
00022 #include "sqlite3.h"
00023 
00024 namespace sqlhelpers
00025 {
00026 
00029 void OneShot(sqlite3 *,const char *);
00031 void OneShot(sqlite3 *,NSString *);
00032 
00036 class StatementRead
00037 {
00038 public:
00040         StatementRead(sqlite3 *db,const char *,bool justRun=false);
00041         StatementRead(sqlite3 *db,NSString *,bool justRun=false);
00043         ~StatementRead();
00044         
00047         bool stepRow();
00048 
00050         void finalize();
00051         
00053         int getInt();
00055         double getDouble();     
00057         NSString *getString();
00059         BOOL getBool();
00060         
00061 protected:
00062         void init(sqlite3 *db,const char *,bool justRun=false);
00063         
00064         sqlite3 *db;
00065         sqlite3_stmt *stmt;
00066         bool isFinalized;
00067         int curField;
00068 };
00069 
00072 class StatementWrite
00073 {
00074 public:
00075         StatementWrite(sqlite3 *db,const char *);
00076         StatementWrite(sqlite3 *db,NSString *);
00077         ~StatementWrite();
00078         
00081         void go();
00082         
00084         void finalize();
00085         
00087         void add(int);
00089         void add(double);
00091         void add(NSString *);
00093         void add(BOOL);
00094         
00095 protected:
00096         void init(sqlite3 *db,const char *);
00097         
00098         sqlite3_stmt *stmt;
00099         bool isFinalized;
00100         int curField;
00101 };      
00102 
00103 }