Makefile was outdated

- Added Column.o and Transaction.o
- Added more gcc warnings in Makefile
- Fix for those warnings
- Added TODO for improvements
This commit is contained in:
Sébastien Rombauts 2012-10-25 22:47:03 +02:00
parent 37a760945c
commit ab55e695af
13 changed files with 47 additions and 34 deletions

View File

@ -22,7 +22,7 @@
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.25715897" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.25715897" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder buildPath="${workspace_loc:/SQLiteC++/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.1197823563" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> <builder buildPath="${workspace_loc:/SQLiteC++/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.1197823563" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.836634439" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> <tool id="cdt.managedbuild.tool.gnu.archiver.base.836634439" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1817615032" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> <tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1817615032" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.750523151" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.750523151" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1248186067" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1248186067" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1310903331" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1310903331" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
@ -50,6 +50,13 @@
</folderInfo> </folderInfo>
</configuration> </configuration>
</storageModule> </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
<path value=""/>
</doc-comment-owner>
</storageModule>
<storageModule moduleId="scannerConfiguration"> <storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
@ -465,13 +472,6 @@
</profile> </profile>
</scannerConfigBuildInfo> </scannerConfigBuildInfo>
</storageModule> </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
<path value=""/>
</doc-comment-owner>
</storageModule>
</cconfiguration> </cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.326780594"> <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.326780594">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.326780594" moduleId="org.eclipse.cdt.core.settings" name="Release"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.326780594" moduleId="org.eclipse.cdt.core.settings" name="Release">
@ -516,6 +516,13 @@
</folderInfo> </folderInfo>
</configuration> </configuration>
</storageModule> </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
<path value=""/>
</doc-comment-owner>
</storageModule>
<storageModule moduleId="scannerConfiguration"> <storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
@ -931,13 +938,6 @@
</profile> </profile>
</scannerConfigBuildInfo> </scannerConfigBuildInfo>
</storageModule> </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
<path value=""/>
</doc-comment-owner>
</storageModule>
</cconfiguration> </cconfiguration>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">

1
.gitignore vendored
View File

@ -5,4 +5,5 @@ Release
*.suo *.suo
*.user *.user
*~ *~
doc
core core

View File

@ -5,7 +5,7 @@
CXX = g++ CXX = g++
# flags for C++ # flags for C++
CXXFLAGS ?= -Wall CXXFLAGS ?= -Wall -Wextra -pedantic -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wundef -Wshadow -Wcast-qual -Wconversion -Wlogical-op -Winline -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn
# [Debug,Release] # [Debug,Release]
BUILD ?= Debug BUILD ?= Debug
@ -13,13 +13,13 @@ BUILD ?= Debug
### Conditionally set variables: ### ### Conditionally set variables: ###
ifeq ($(BUILD),Debug) ifeq ($(BUILD),Debug)
BUILD_FLAGS = -g -rdynamic -fno-inline -O0 -DDEBUG -D_DEBUG BUILD_FLAGS = -g3 -rdynamic -fstack-protector-all -fno-inline -O0 -DDEBUG -D_DEBUG
endif endif
ifeq ($(BUILD),Release) ifeq ($(BUILD),Release)
BUILD_FLAGS = -O2 BUILD_FLAGS = -O2
endif endif
ifeq ($(BUILD),Debug) ifeq ($(BUILD),Debug)
LINK_FLAGS = -g -rdynamic LINK_FLAGS = -g3 -rdynamic
endif endif
ifeq ($(BUILD),Release) ifeq ($(BUILD),Release)
LINK_FLAGS = LINK_FLAGS =
@ -32,8 +32,10 @@ CPPDEPS = -MT $@ -MF`echo $@ | sed -e 's,\.o$$,.d,'` -MD -MP
SQLITE_CXXFLAGS = $(BUILD_FLAGS) $(CXXFLAGS) SQLITE_CXXFLAGS = $(BUILD_FLAGS) $(CXXFLAGS)
SQLITE_EXAMPLE1_OBJECTS = \ SQLITE_EXAMPLE1_OBJECTS = \
$(BUILD)/main.o \ $(BUILD)/main.o \
$(BUILD)/Column.o \
$(BUILD)/Database.o \ $(BUILD)/Database.o \
$(BUILD)/Statement.o \ $(BUILD)/Statement.o \
$(BUILD)/Transaction.o \
### Targets: ### ### Targets: ###
@ -55,12 +57,18 @@ $(BUILD)/example1: $(SQLITE_EXAMPLE1_OBJECTS)
$(BUILD)/main.o: src/example1/main.cpp $(BUILD)/main.o: src/example1/main.cpp
$(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $< $(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $<
$(BUILD)/Column.o: src/SQLiteC++/Column.cpp
$(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $<
$(BUILD)/Database.o: src/SQLiteC++/Database.cpp $(BUILD)/Database.o: src/SQLiteC++/Database.cpp
$(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $< $(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $<
$(BUILD)/Statement.o: src/SQLiteC++/Statement.cpp $(BUILD)/Statement.o: src/SQLiteC++/Statement.cpp
$(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $< $(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $<
$(BUILD)/Transaction.o: src/SQLiteC++/Transaction.cpp
$(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $<
.PHONY: all clean .PHONY: all clean
@ -68,3 +76,4 @@ $(BUILD)/Statement.o: src/SQLiteC++/Statement.cpp
# Dependencies tracking: # Dependencies tracking:
-include $(BUILD)/*.d -include $(BUILD)/*.d

View File

@ -76,4 +76,4 @@ std::ostream& operator<<(std::ostream &stream, const Column& column)
return stream; return stream;
} }
}; // namespace SQLite } // namespace SQLite

View File

@ -43,17 +43,17 @@ public:
const char* getText (void) const throw(); const char* getText (void) const throw();
/// Inline cast operator to int /// Inline cast operator to int
inline operator const int() const inline operator int() const
{ {
return getInt(); return getInt();
} }
/// Inline cast operator to 64bits integer /// Inline cast operator to 64bits integer
inline operator const sqlite3_int64() const inline operator sqlite3_int64() const
{ {
return getInt64(); return getInt64();
} }
/// Inline cast operator to double /// Inline cast operator to double
inline operator const double() const inline operator double() const
{ {
return getDouble(); return getDouble();
} }
@ -71,6 +71,7 @@ public:
private: private:
// Column is copyable, but copy should not be used elsewhere than in return form getColumn // Column is copyable, but copy should not be used elsewhere than in return form getColumn
Column(void); Column(void);
// TODO Column(const Column&);
Column& operator=(const Column&); Column& operator=(const Column&);
private: private:
@ -83,4 +84,4 @@ private:
/// Standard std::ostream inserter /// Standard std::ostream inserter
std::ostream& operator<<(std::ostream &stream, const Column& column); std::ostream& operator<<(std::ostream &stream, const Column& column);
}; // namespace SQLite } // namespace SQLite

View File

@ -19,6 +19,7 @@ Database::Database(const char* apFilename, const int aFlags /*= SQLITE_OPEN_READ
mpSQLite(NULL), mpSQLite(NULL),
mFilename(apFilename) mFilename(apFilename)
{ {
// TODO SRombauts : add a :memory: mode, and a backup to/from :memory:
int ret = sqlite3_open_v2(apFilename, &mpSQLite, aFlags, NULL); int ret = sqlite3_open_v2(apFilename, &mpSQLite, aFlags, NULL);
if (SQLITE_OK != ret) if (SQLITE_OK != ret)
{ {

View File

@ -136,4 +136,4 @@ private:
}; };
}; // namespace SQLite } // namespace SQLite

View File

@ -31,4 +31,4 @@ public:
}; };
}; // namespace SQLite } // namespace SQLite

View File

@ -184,4 +184,4 @@ private:
bool mbDone; //!< True when the last executeStep() had no more row to fetch bool mbDone; //!< True when the last executeStep() had no more row to fetch
}; };
}; // namespace SQLite } // namespace SQLite

View File

@ -46,4 +46,4 @@ void Transaction::commit(void) // throw(SQLite::Exception)
} }
}; // namespace SQLite } // namespace SQLite

View File

@ -61,4 +61,4 @@ private:
}; };
}; // namespace SQLite } // namespace SQLite

View File

@ -85,10 +85,10 @@ int main (void)
// Demonstrate how to get some typed column value // Demonstrate how to get some typed column value
int id = query.getColumn(0); // = query.getColumn(0).getInt() int id = query.getColumn(0); // = query.getColumn(0).getInt()
//const char* pvalue = query.getColumn(1); // = query.getColumn(1).getText() //const char* pvalue = query.getColumn(1); // = query.getColumn(1).getText()
std::string value = query.getColumn(1); // = query.getColumn(1).getText() std::string value2 = query.getColumn(1); // = query.getColumn(1).getText()
int size = query.getColumn(2); // = query.getColumn(2).getInt() int size = query.getColumn(2); // = query.getColumn(2).getInt()
std::cout << "row : (" << id << ", " << value.c_str() << ", " << size << ")\n"; std::cout << "row : (" << id << ", " << value2.c_str() << ", " << size << ")\n";
} }
// Reset the query to use it again // Reset the query to use it again
@ -204,8 +204,8 @@ int main (void)
int nb = db.exec("INSERT INTO test VALUES (NULL, \"second\")"); int nb = db.exec("INSERT INTO test VALUES (NULL, \"second\")");
std::cout << "INSERT INTO test VALUES (NULL, \"second\")\", returned " << nb << std::endl; std::cout << "INSERT INTO test VALUES (NULL, \"second\")\", returned " << nb << std::endl;
nb = db.exec("INSERT INTO test \"error\""); nb = db.exec("INSERT INTO test ObviousError");
std::cout << "INSERT INTO test \"error\"\", returned " << nb << std::endl; std::cout << "INSERT INTO test \"error\", returned " << nb << std::endl;
// Commit transaction // Commit transaction
transaction.commit(); transaction.commit();

1
src/sqlite3/README.txt Normal file
View File

@ -0,0 +1 @@
sqlite3.c and sqlite3.h are not used by the default Linux Makefile (which thus requires the Linux libsqlite3-dev package) but is used by the Visual Studio solution.