summaryrefslogtreecommitdiff
path: root/slicer/db/sqlCommon.cpp
blob: 5618b2956f5daa85c235c23f492472ba652658ad (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(HookCommonPtr h)
	{
		return metaDataFlagSet(h->GetMetadata(), md_pkey) && isBind(h);
	}

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

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

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

	bool isValue(HookCommonPtr 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);
	}

}