Module: CxxesHelper
- Included in:
- CxxesContext
- Defined in:
- app/helpers/cxxes_helper.rb,
lib/generators/sqlpp11gen/cxxes_helper.rb
Instance Method Summary collapse
Instance Method Details
#buildCtor(cols) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/cxxes_helper.rb', line 35 def buildCtor(cols) a = [] cols.each do |col| coltype = col.type.to_s if coltype == 'integer' a << col.name + '(0)' elsif coltype == 'boolean' a << col.name + '(false)' elsif coltype == 'decimal' a << col.name + '(0.0f)' end end a.join(', ') end |
#coltype2ctype(coltype) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/cxxes_helper.rb', line 3 def coltype2ctype(coltype) if coltype == 'integer' then ctype = 'std::int64_t' elsif coltype == 'string' || coltype == 'text' then ctype = 'std::string' elsif coltype == 'datetime' or coltype.start_with?("timestamp") then ctype = 'sqlpp::chrono::microsecond_point' elsif coltype == 'decimal' then ctype = 'double' elsif coltype == 'boolean' then ctype = 'bool' else ctype = coltype end ctype end |
#sqlpptype(coltype) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/cxxes_helper.rb', line 20 def sqlpptype(coltype) case coltype when /datetime/, /\Atimestamp/ "time_point" when /decimal/, /numeric/ "floating_point" when /character varying/, /\Avarchar/ "varchar" when /int/ "integer" else coltype end end |