summaryrefslogtreecommitdiff
path: root/slicer/db/sqlCommon.cpp
blob: ecce6cc99b080b75aba5e5fcbeccb61fcf70226a (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
62
63
64
65
66
67
68
69
#include "sqlCommon.h"
#include <compileTimeFormatter.h>
#include <metadata.h>
#include <sqlExceptions.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);
	}

}