= defstr
* http://defstr.rubyforge.org/
* http://rubyforge.org/projects/defstr/
== DESCRIPTION:
defstr converts text to a C string literal
that parses (by a C compiler) to the original text, and creates
a C macro that defines it as a constant. The liternal preserves
the original text's structure (line breaks, paragraphs, etc).
defstr can be used as a tool for C/C++ code generation.
== Library Usage:
Use Defstr.string_literal to convert a string to a C literal. For example:
require 'defstr'
Defstr.string_literal "abc"
gets you a ruby string that represents the text:
"\
abc"
User Defstr.define_string to define the string as a constant. For example:
require 'defstr'
Defstr.define_string("CG_VERTEX_PROGRAM", <<EOF
void main(float3 position : POSITION,
out float3 clipPosition : POSITION)
{
clipPosition = position;
}
EOF
)
gets you a ruby string that represents the text:
#define CG_VERTEX_PROGRAM "\
void main(float3 position : POSITION,\n\
out float3 clipPosition : POSITION)\n\
{\n\
clipPosition = position;\n\
}\n\
"
== Shell Command Usage:
Suppose the content of vertex_program.cg is the same as
the program snipper defined in a string above. After you run
$ defstr CG_VERTEX_PROGRAM < vertex_program.cg > vertex_program_string.h
the content of vertex_program_string.h will be:
#ifndef __DEFSTR_CG_VERTEX_PROGRAM_H__
#define __DEFSTR_CG_VERTEX_PROGRAM_H__
#define CG_VERTEX_PROGRAM "\
void main(float3 position : POSITION,\n\
out float3 clipPosition : POSITION)\n\
{\n\
clipPosition = position;\n\
}\n\
"
#endif
If you do not want the #ifndef, use the --no-ifndef flag. For example:
$ defstr CG_VERTEX_PROGRAM < vertex_program.cg > vertex_program_string.h --no-ifndef
will write the following text:
#define CG_VERTEX_PROGRAM "\
void main(float3 position : POSITION,\n\
out float3 clipPosition : POSITION)\n\
{\n\
clipPosition = position;\n\
}\
"
to vertex_program_string.h
== Requirements:
=== For Development:
* hoe >= 1.7.0
== INSTALL:
* sudo gem install defstr
== LICENSE:
(The MIT License)
Copyright (c) 2008 Pramook Khungurn
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* http://defstr.rubyforge.org/
* http://rubyforge.org/projects/defstr/
== DESCRIPTION:
defstr converts text to a C string literal
that parses (by a C compiler) to the original text, and creates
a C macro that defines it as a constant. The liternal preserves
the original text's structure (line breaks, paragraphs, etc).
defstr can be used as a tool for C/C++ code generation.
== Library Usage:
Use Defstr.string_literal to convert a string to a C literal. For example:
require 'defstr'
Defstr.string_literal "abc"
gets you a ruby string that represents the text:
"\
abc"
User Defstr.define_string to define the string as a constant. For example:
require 'defstr'
Defstr.define_string("CG_VERTEX_PROGRAM", <<EOF
void main(float3 position : POSITION,
out float3 clipPosition : POSITION)
{
clipPosition = position;
}
EOF
)
gets you a ruby string that represents the text:
#define CG_VERTEX_PROGRAM "\
void main(float3 position : POSITION,\n\
out float3 clipPosition : POSITION)\n\
{\n\
clipPosition = position;\n\
}\n\
"
== Shell Command Usage:
Suppose the content of vertex_program.cg is the same as
the program snipper defined in a string above. After you run
$ defstr CG_VERTEX_PROGRAM < vertex_program.cg > vertex_program_string.h
the content of vertex_program_string.h will be:
#ifndef __DEFSTR_CG_VERTEX_PROGRAM_H__
#define __DEFSTR_CG_VERTEX_PROGRAM_H__
#define CG_VERTEX_PROGRAM "\
void main(float3 position : POSITION,\n\
out float3 clipPosition : POSITION)\n\
{\n\
clipPosition = position;\n\
}\n\
"
#endif
If you do not want the #ifndef, use the --no-ifndef flag. For example:
$ defstr CG_VERTEX_PROGRAM < vertex_program.cg > vertex_program_string.h --no-ifndef
will write the following text:
#define CG_VERTEX_PROGRAM "\
void main(float3 position : POSITION,\n\
out float3 clipPosition : POSITION)\n\
{\n\
clipPosition = position;\n\
}\
"
to vertex_program_string.h
== Requirements:
=== For Development:
* hoe >= 1.7.0
== INSTALL:
* sudo gem install defstr
== LICENSE:
(The MIT License)
Copyright (c) 2008 Pramook Khungurn
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.