dm-metamapper 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  module DataMapper
2
2
  module MetaMapper
3
- VERSION = "0.2.0" unless defined?(::DataMapper::MetaMapper::VERSION)
3
+ VERSION = "0.2.1" unless defined?(::DataMapper::MetaMapper::VERSION)
4
4
  end
5
5
 
6
6
  end
@@ -60,28 +60,30 @@ public:
60
60
  }
61
61
  <%- end -%>
62
62
 
63
- void getFields(std::vector<std::string>& rFields)
63
+ std::vector<std::string> getFields()
64
64
  {
65
- rFields.clear();
65
+ std::vector<std::string> ret;
66
+ ret.clear();
66
67
  <%- model.generated_properties.each do |property| -%>
67
- rFields.push_back("<%= property.name %>");
68
+ ret.push_back("<%= property.name %>");
68
69
  <%- end -%>
70
+ return ret;
69
71
  }
70
72
 
71
- void select(const Condition& c,
72
- const std::string& additional,
73
- std::vector<O_<%= class_name %>>& r)
73
+ std::vector<O_<%= class_name %>>
74
+ select(const Condition& c,
75
+ const std::string& additional)
74
76
  {
77
+ std::vector<O_<%= class_name %>> ret;
75
78
  Condition c1 = _constraint.nil() ? c : _constraint && c;
76
- std::vector<std::string> fields;
77
- getFields(fields);
79
+ std::vector<std::string> fields = getFields();
78
80
  QueryRes res;
79
81
  DBFace::instance()->select(_tables, fields, c1._cond,
80
82
  additional, res);
81
- r.resize(res.size());
83
+ ret.resize(res.size());
82
84
  for(size_t i = 0; i < res.size(); ++i){
83
85
  <%- model.generated_properties.each do |property| -%>
84
- r[i]._f_<%= property.name %>._base =
86
+ ret[i]._f_<%= property.name %>._base =
85
87
  <%- if DataMapper::Property::Enum === property -%>
86
88
  (<%= property.cpp_name %>::Base)UTILS::fromString<size_t>(res[i]["<%= property.name %>"]);
87
89
  <%- else -%>
@@ -89,6 +91,7 @@ public:
89
91
  <%- end -%>
90
92
  <%- end -%>
91
93
  }
94
+ return ret;
92
95
  }
93
96
 
94
97
  size_t count(const Condition& c)
@@ -109,16 +112,15 @@ public:
109
112
  }
110
113
 
111
114
 
112
- void select(const Condition& c,
113
- std::vector<O_<%= class_name %>>& r)
115
+ std::vector<O_<%= class_name %>> select(const Condition& c)
114
116
  {
115
117
  Condition c1 = _constraint.nil() ? c : _constraint && c;
116
- select(c1, "", r);
118
+ return select(c1, "");
117
119
  }
118
120
 
119
- void select(std::vector<O_<%= class_name %>>& r)
121
+ std::vector<O_<%= class_name %>> select()
120
122
  {
121
- select(_constraint, "", r);
123
+ return select(_constraint, "");
122
124
  }
123
125
 
124
126
  std::pair<O_<%= class_name %>, bool> select(const I_<%= class_name %>& id){
@@ -128,8 +130,7 @@ public:
128
130
  std::pair<O_<%= class_name %>, bool> first(const Condition& c)
129
131
  {
130
132
  Condition c1 = _constraint.nil() ? c : _constraint && c;
131
- std::vector<O_<%= class_name %>> r;
132
- select(c, "limit 1", r);
133
+ std::vector<O_<%= class_name %>> r = select(c, "limit 1");
133
134
  if(r.size() > 0)
134
135
  return std::make_pair(r[0], true);
135
136
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-metamapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonah Honeyman
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-12-04 00:00:00 Z
19
+ date: 2012-01-02 00:00:00 Z
20
20
  dependencies: []
21
21
 
22
22
  description: C++ API for databases created with DM. Hard typing, compile time checked queries.