Skip to content

Commit

Permalink
ximport feature
Browse files Browse the repository at this point in the history
  • Loading branch information
webern committed Aug 22, 2016
1 parent 0230208 commit 53fd585
Show file tree
Hide file tree
Showing 2,153 changed files with 794,105 additions and 597,390 deletions.
Empty file modified .gitattributes
100644 → 100755
Empty file.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Xcode/mx.xcworkspace/xcuserdata/
Proj/
*/project.xcworkspace/

#####################################
# Ignore Test Output Files #
#####################################
#########################################
# Ignore Test Output and Expected Files #
#########################################
Resources/testOutput/*.xml
Resources/testOutput/*.txt
Resources/testOutput/*.csv
Resources/expected/

#####################################
# Stuff I found online #
Expand Down
Binary file added DevScripts/ElementsOrder.xlsx
Binary file not shown.
File renamed without changes.
25 changes: 25 additions & 0 deletions DevScripts/adjustElementsCpp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
lines = []

File.open("../Sourcecode/mx/core/Elements.cpp", "r") do |input_file|
input_file.each_line do |line|
lines << line
end
end

File.open("../Sourcecode/mx/core/Elements.cpp.replace", "w") do |f|
write_line = true
lines.each do |line|

rx = /^\s*$/
skip_line = ( line =~ rx ) != nil


if !skip_line
f << line
end



end
end

36 changes: 36 additions & 0 deletions DevScripts/adjustElementsH.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
lines = []

File.open("../Sourcecode/mx/core/Elements.h", "r") do |input_file|
input_file.each_line do |line|
lines << line
end
end

File.open("../Sourcecode/mx/core/Elements.h.replace", "w") do |f|
write_line = true
lines.each do |line|


rx = /^((?!\/\*\s\_\_\_).)*$/
is_not_a_good_comment = ( line =~ rx ) != nil

rx = /\/\*/
is_a_comment = ( line =~ rx ) != nil

if is_not_a_good_comment && is_a_comment
write_line = false
end

if write_line
f << line
end

rx = /\*\//

if ( line =~ rx ) != nil
write_line = true
end

end
end

130 changes: 130 additions & 0 deletions DevScripts/arrowGroup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@

require 'stringio'

class String
def uncapitalize
self[0, 1].downcase + self[1..-1]
end
end

class Member
attr_accessor :my_variable_name
attr_accessor :element_name
attr_accessor :is_set
attr_accessor :is_required
attr_accessor :element_name_for_cpp

def initialize in_my_variable_name, in_element_name, in_description, in_element_name_for_cpp
@my_variable_name = in_my_variable_name
@element_name = in_element_name
@element_name_for_cpp = in_element_name_for_cpp

if in_description.eql? "collection"
@is_set = true
@is_required = false
elsif in_description.eql? "required"
@is_set = false
@is_required = true
elsif in_description.eql? "optional"
@is_set = false
@is_required = false
else
@is_set = false
@is_required = false
end
end

def is_found_variable
"is#{element_name_for_cpp}Found"
end

def is_first_added_variable
"isFirst#{element_name_for_cpp}Added"
end

end

=begin
example_required_single = Member.new "myCreditWords", "credit-words", "required", "CreditWords"
example_optional_single = Member.new "myOptionalThing", "optional-thing", "optional", "OptionalThing"
example_collection = Member.new "myCatSet", "cat", "collection", "Cat"
=end

group_class_name = "ArrowGroup"

members = []

#sample code
members << Member.new( "myArrowDirection", "arrow-direction", "required", "ArrowDirection" )
members << Member.new( "myArrowStyle", "arrow-style", "optional", "ArrowStyle" )

code = StringIO.new
tab = " "
code << tab << tab << "bool #{group_class_name}::fromXElement( std::ostream& message, xml::XElement& xelement )" << "\n"
code << tab << tab << "{" << "\n"
code << tab << tab << tab << "bool isSuccess = true;" << "\n"

members.each do |m|
if m.is_required && !m.is_set
code << tab << tab << tab << "bool #{m.is_found_variable} = false;" << "\n"
elsif m.is_set
code << tab << tab << tab << "bool #{m.is_first_added_variable} = false;" << "\n"
end
end
code << "\n"
code << tab << tab << tab << "for( auto it = xelement.elementsBegin(); it != xelement.elementsEnd(); ++it )" << "\n"
code << tab << tab << tab << "{" << "\n"
code << tab << tab << tab << tab << "const std::string elementName = it->getName();" << "\n"
code << "\n"
first_if = true
members.each do |m|

code << tab << tab << tab << tab
if !first_if
code << "else "
end
first_if = false
code << "if( elementName == \"#{m.element_name}\" )" << "\n"
code << tab << tab << tab << tab << "{" << "\n"
if m.is_set
code << " auto #{m.element_name_for_cpp.uncapitalize} = make#{m.element_name_for_cpp.uncapitalize}();" << "\n"
code << " isSuccess &= #{m.element_name_for_cpp.uncapitalize}->fromXElement( message, *it );" << "\n"
code << "\n"
code << " if( !#{m.is_first_added_variable} && #{m.my_variable_name}.size() == 1 )" << "\n"
code << " {" << "\n"
code << " *( #{m.my_variable_name}.begin() ) = #{m.element_name_for_cpp.uncapitalize};" << "\n"
code << " #{m.is_first_added_variable} = true;" << "\n"
code << " }" << "\n"
code << " else" << "\n"
code << " {" << "\n"
code << " #{m.my_variable_name}.push_back( #{m.element_name_for_cpp.uncapitalize} );" << "\n"
code << " #{m.is_first_added_variable} = true;" << "\n"
code << " }" << "\n"
elsif m.is_required
code << " #{m.is_found_variable} = true;" << "\n"
code << " isSuccess &= #{m.my_variable_name}->fromXElement( message, *it );" << "\n"
else
code << " myHas#{m.element_name_for_cpp} = true;" << "\n"
code << " isSuccess &= #{m.my_variable_name}->fromXElement( message, *it );" << "\n"
end
code << tab << tab << tab << tab << "}" << "\n"
end
code << tab << tab << tab << tab << "else" << "\n"
code << tab << tab << tab << tab << "{" << "\n"

members.each do |m|
if m.is_required
code << " if( !#{m.is_found_variable} )" << "\n"
code << " {" << "\n"
code << " isSuccess = false;" << "\n"
code << " message << \"#{group_class_name}: '#{m.element_name}' element is required but was not found\" << std::endl;" << "\n"
code << " }" << "\n"
end
end
code << " break;" << "\n"
code << tab << tab << tab << tab << "}" << "\n"
code << tab << tab << tab << "}" << "\n"
code << tab << tab << tab << "return isSuccess;" << "\n"
code << tab << tab << "}" << "\n"

puts code.string
Loading

0 comments on commit 53fd585

Please sign in to comment.