summaryrefslogtreecommitdiff
path: root/slicer/db/sqlCommon.cpp
blob: 193285e03bb2131b601f3957d0394db15d418842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <sqlExceptions.h>
#include <compileTimeFormatter.h>
#include "sqlCommon.h"
#include <metadata.h>

namespace Slicer {
	const std::string md_pkey = "db:pkey";
	const std::string md_auto = "db:auto";
	const std::string md_ignore = "db:ignore";
	const std::string md_global_ignore = "ignore";

	bool isPKey(const HookCommon * h)
	{
		return metaDataFlagSet(h->GetMetadata(), md_pkey) && isBind(h);
	}

	bool isAuto(const HookCommon * h)
	{
		return metaDataFlagSet(h->GetMetadata(), md_auto) && isBind(h);
	}

	bool isNotAuto(const HookCommon * h)
	{
		return metaDataFlagNotSet(h->GetMetadata(), md_auto) && isBind(h);
	}

	bool isBind(const HookCommon * h)
	{
		return metaDataFlagNotSet(h->GetMetadata(), md_global_ignore) &&
			metaDataFlagNotSet(h->GetMetadata(), md_ignore);
	}

	bool isValue(const HookCommon * h)
	{
		return metaDataFlagNotSet(h->GetMetadata(), md_auto) &&
			metaDataFlagNotSet(h->GetMetadata(), md_pkey) && isBind(h);
	}

	void TooManyRowsReturned::ice_print(std::ostream & s) const
	{
		s << "Too many rows returned";
	}

	void NoRowsReturned::ice_print(std::ostream & s) const
	{
		s << "No rows returned";
	}

	void NoRowsFound::ice_print(std::ostream & s) const
	{
		s << "No rows found";
	}

	AdHocFormatter(UnsuitableIdFieldTypeMsg, "Unsuitable id field type [%?]");
	void UnsuitableIdFieldType::ice_print(std::ostream & s) const
	{
		UnsuitableIdFieldTypeMsg::write(s, type);
	}

}