Module: Erubis::CppGenerator

### Home Classes Methods

### In Files

- lib/erubis/engine/ecpp.rb

### Methods

- #add_expr_debug
- #add_expr_escaped
- #add_expr_literal
- #add_postamble
- #add_preamble
- #add_stmt
- #add_text
- #escape_text
- #escaped_expr
- #init_generator

### Included Modules

- Erubis::Generator

### Class/Module Index

Quicksearch

- Erubis
- Erubis::ArrayBufferEnhancer
- Erubis::ArrayBufferEruby
- Erubis::ArrayEnhancer
- Erubis::ArrayEruby
- Erubis::Basic
- Erubis::Basic::Converter
- Erubis::Basic::Engine
- Erubis::BiPatternEnhancer
- Erubis::BiPatternEruby
- Erubis::CGenerator
- Erubis::CommandOptionError
- Erubis::Context
- Erubis::Converter
- Erubis::CppGenerator
- Erubis::DeleteIndentEnhancer
- Erubis::DeleteIndentEruby
- Erubis::Ec
- Erubis::Ecpp
- Erubis::Ejava
- Erubis::Ejavascript
- Erubis::Ejs
- Erubis::Engine
- Erubis::Eperl
- Erubis::Ephp
- Erubis::ErboutEnhancer
- Erubis::ErboutEruby
- Erubis::ErubisError
- Erubis::Eruby
- Erubis::EscapeEnhancer
- Erubis::EscapedEc
- Erubis::EscapedEcpp
- Erubis::EscapedEjava
- Erubis::EscapedEjavascript
- Erubis::EscapedEjs
- Erubis::EscapedEperl
- Erubis::EscapedEphp
- Erubis::EscapedEruby
- Erubis::EscapedEscheme
- Erubis::Escheme
- Erubis::Evaluator
- Erubis::FastEruby
- Erubis::Generator
- Erubis::HeaderFooterEnhancer
- Erubis::HeaderFooterEruby
- Erubis::Helpers
- Erubis::Helpers::RailsFormHelper
- Erubis::Helpers::RailsHelper
- Erubis::Helpers::RailsHelper::TemplateConverter
- Erubis::InterpolationEnhancer
- Erubis::InterpolationEruby
- Erubis::JavaGenerator
- Erubis::JavascriptGenerator
- Erubis::Main
- Erubis::NoCodeEnhancer
- Erubis::NoCodeEruby
- Erubis::NoTextEnhancer
- Erubis::NoTextEruby
- Erubis::NotSupportedError
- Erubis::OptimizedEruby
- Erubis::OptimizedGenerator
- Erubis::OptimizedXmlEruby
- Erubis::PI
- Erubis::PI::Converter
- Erubis::PI::Ec
- Erubis::PI::Ecpp
- Erubis::PI::Ejava
- Erubis::PI::Ejavascript
- Erubis::PI::Engine
- Erubis::PI::Eperl
- Erubis::PI::Ephp
- Erubis::PI::Eruby
- Erubis::PI::Escheme
- Erubis::PI::TinyEruby
- Erubis::PercentLineEnhancer
- Erubis::PercentLineEruby
- Erubis::PerlGenerator
- Erubis::PhpGenerator
- Erubis::PrefixedLineEnhancer
- Erubis::PrefixedLineEruby
- Erubis::PreprocessingEruby
- Erubis::PreprocessingHelper
- Erubis::PrintEnabledEnhancer
- Erubis::PrintEnabledEruby
- Erubis::PrintOutEnhancer
- Erubis::PrintOutEruby
- Erubis::PrintOutSimplifiedEruby
- Erubis::RubyEvaluator
- Erubis::RubyGenerator
- Erubis::SchemeGenerator
- Erubis::SimplifiedEruby
- Erubis::SimplifyEnhancer
- Erubis::StdoutEnhancer
- Erubis::StdoutEruby
- Erubis::StdoutSimplifiedEruby
- Erubis::StringBufferEnhancer
- Erubis::StringBufferEruby
- Erubis::StringIOEruby
- Erubis::TinyEruby
- Erubis::XmlEruby
- Erubis::XmlHelper
- ActionView
- ActionView::TemplateHandlers
- ActionView::TemplateHandlers::ErubisHandler
- ERB
- Kernel

No matching classes.

# Erubis::CppGenerator

### Public Instance Methods

add_expr_debug(src, code) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 72
    def add_expr_debug(src, code)
      code.strip!
      src << @indent if src.empty? || src[-1] == \n\
      src << " std::cerr << \"*** debug: #{code.gsub(/(")/, '\\\&')}=\" << (#{code});"
    end

add_expr_escaped(src, code) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 67
    def add_expr_escaped(src, code)
      src << @indent if src.empty? || src[-1] == \n\
      src << ' ' << escaped_expr(code) << ';'
    end

add_expr_literal(src, code) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 62
    def add_expr_literal(src, code)
      src << @indent if src.empty? || src[-1] == \n\
      src << " _buf << (" << code.strip << ");"
    end

add_postamble(src) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 78
    def add_postamble(src)
      # empty
    end

add_preamble(src) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 30
    def add_preamble(src)
      src << "#line 1 \"#{self.filename}\"\n" if self.filename
    end

add_stmt(src, code) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 58
    def add_stmt(src, code)
      src << code
    end

add_text(src, text) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 44
    def add_text(src, text)
      return if text.empty?
      src << (src.empty? || src[-1] == \n\ ? @indent : ' ')
      src << "_buf << "
      i = 0
      text.each_line do |line|
        src << "\n" << @indent << "        " if i > 0
        i += 1
        src << '"' << escape_text(line) << '"'
      end
      src << ";"   #<< (text[-1] == ?\n ? "\n" : "")
      src << "\n" if text[-1] == \n\
    end

escape_text(text) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 34
    def escape_text(text)
      @@table_ ||= { "\r"=>"\\r", "\n"=>"\\n", "\t"=>"\\t", '"'=>'\"', "\\"=>"\\\\" }
      text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] }
      return text
    end

escaped_expr(code) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 40
    def escaped_expr(code)
      return "#{@escapefunc}(#{code.strip})"
    end

init_generator(properties={}) click to toggle source

    # File lib/erubis/engine/ecpp.rb, line 23
    def init_generator(properties={})
      super
      @escapefunc ||= "escape"
      @indent = properties[:indent] || ''
      @bufvar = properties[:bufvar] || '_buf'
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.