Skip to content

Commit

Permalink
start of simple inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cruisercoder committed Feb 24, 2018
1 parent 806236e commit 25f0291
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 19 deletions.
60 changes: 50 additions & 10 deletions src/std/database/front.d → src/std/database/BasicDatabase.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module std.database.front;
module std.database.BasicDatabase;
import std.experimental.logger;
import std.database.exception;
import std.datetime;
Expand All @@ -17,19 +17,33 @@ import std.variant;
import std.range.primitives;
import std.database.option;

public import std.database.array;
/**
BasicDatabase: a common and generic front-end for database access
Typically, this interface is impliclity used when import a specific database
driver as shown in this simple example:
---
import std.database.sqlite;
auto db = createDatabase("file:///testdb");
auto rows = db.connection.query("select name,score from score").rows;
foreach (r; rows) {
writeln(r[0].as!string,",",r[1].as!int);
}
---
/*
require a specific minimum version of DMD (2.071)
can't use yet because DMD is reporting wrong version
For advanced usage, you can also explicitly instantiate a BasicDatabase
with a driver:
---
import std.database;
alias DB = BasicDatabase!(MyDriver!MyPolicy, MyPolicy);
---
import std.compiler;
static assert(
name != "Digital Mars D" ||
(version_major == 2 && version_minor == 70));
*/
*/


public import std.database.array;

enum ValueType {
Int,
String,
Expand All @@ -53,6 +67,10 @@ enum Feature {

alias FeatureArray = Feature[];

/**
A root type for interacting with databases. It's primary purpose is act as
a factory for database connections. This type can be shared across threads.
*/
struct BasicDatabase(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down Expand Up @@ -125,6 +143,9 @@ auto ref driverDatabase() {return data_.database;}
}
}

/**
Holds a connection to the database.
*/
struct BasicConnection(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down Expand Up @@ -205,6 +226,9 @@ data_ = Data(&db.data_.refCountedPayload(),uri);

}

/**
Manages statement details such as query execution and input binding.
*/
struct BasicStatement(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down Expand Up @@ -314,6 +338,10 @@ struct BasicStatement(D,P) {
}


/**
An internal class for result access and iteration. See the RowSet type for range based access
to results
*/
struct BasicResult(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down Expand Up @@ -371,6 +399,9 @@ package:
}
}

/**
A range over result column information
*/
struct BasicColumnSet(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down Expand Up @@ -415,6 +446,9 @@ struct BasicColumn(D,P) {
}


/**
A input range over the results of a query.
*/
struct BasicRowSet(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down Expand Up @@ -485,6 +519,9 @@ struct BasicRowSet(D,P) {
void popFront() {result_.next();}
}

/**
A row accessor for the current row in a RowSet input range.
*/
struct BasicRow(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down Expand Up @@ -524,6 +561,9 @@ struct BasicRow(D,P) {
}


/**
A value accessor for an indexed value in the current row in a RowSet input range.
*/
struct BasicValue(D,P) {
alias Driver = D;
alias Policy = P;
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/freetds/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import std.typecons;
import std.container.array;
import std.experimental.logger;
public import std.database.allocator;
import std.database.front;
import std.database.BasicDatabase;
import std.datetime;

struct DefaultPolicy {
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/mysql/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ version(Windows) {
import std.database.mysql.bindings;
import std.database.exception;
import std.database.allocator;
import std.database.front;
import std.database.BasicDatabase;
import std.container.array;
import std.experimental.logger;
import std.string;
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/odbc/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import std.typecons;
import std.container.array;
import std.experimental.logger;
public import std.database.allocator;
import std.database.front;
import std.database.BasicDatabase;
import std.datetime;

//alias long SQLLEN;
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/oracle/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import std.container.array;

import std.datetime;

import std.database.front;
import std.database.BasicDatabase;

struct DefaultPolicy {
alias Allocator = MyMallocator;
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/poly/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public import std.database.exception;
import std.stdio;
import std.typecons;
import std.container.array;
import std.database.front;
import std.database.BasicDatabase;
import std.database.allocator;
import std.database.source;
import std.database.common;
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/postgres/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import std.database.source;
import std.database.allocator;
import std.container.array;
import std.experimental.logger;
import std.database.front;
import std.database.BasicDatabase;

import std.stdio;
import std.typecons;
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/rowset.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module std.database.rowset;
import std.database.front;
import std.database.BasicDatabase;
import std.datetime;
import std.container.array;

Expand Down
2 changes: 1 addition & 1 deletion src/std/database/sqlite/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import std.database.source;
import std.database.allocator;
import std.database.pool;
import std.experimental.logger;
import std.database.front;
import std.database.BasicDatabase;

import std.container.array;
import std.datetime;
Expand Down
2 changes: 1 addition & 1 deletion src/std/database/testsuite.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import std.stdio;
import std.experimental.logger;
import std.datetime;

import std.database.front: Feature;
import std.database.BasicDatabase: Feature;

void testAll(Database) (string source) {

Expand Down

0 comments on commit 25f0291

Please sign in to comment.