Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ButtonConstants.au3>
- #include <EditConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <array.au3>
- $gui = GUICreate("Getter Setter", 755, 268, -1, -1)
- $edit1 = GUICtrlCreateEdit("", 0, 0, 345, 265)
- $edit2 = GUICtrlCreateEdit("", 408, 0, 345, 265)
- $go = GUICtrlCreateButton("Go", 355, 100, 45, 25)
- $copy = GUICtrlCreateButton("Copy", 355, 140, 45, 25)
- GUICtrlSetFont($edit1, 9, 400, 0, "Courier New")
- GUICtrlSetFont($edit2, 9, 400, 0, "Courier New")
- GUISetState(@SW_SHOW)
- GUICtrlSetData($edit1, ClipGet())
- Func _trim($s)
- While StringLeft($s,1) == " " Or StringLeft($s,1) = " "
- $s = StringTrimLeft($s, 1)
- WEnd
- While StringRight($s,1) == " " Or StringRight($s,1) = " "
- $s = StringTrimRight($s, 1)
- WEnd
- Return $s
- EndFunc
- Func _StringInStrRight($s, $substring)
- ;reverse
- $sTemp = ""
- For $i = 1 To StringLen($s)
- $sTemp = StringMid($s, $i,1) & $sTemp
- Next
- $i = StringInStr($sTemp, $substring)
- Return stringlen($s) - $i + 1
- EndFunc
- Func _go()
- $input = GUICtrlRead($edit1)
- Dim $aLines = StringSplit($input,@CRLF,1)
- $numLines = $aLines[0]
- $outGet = "//getters" & @CRLF
- $outSet = "//setters" & @CRLF
- For $i = 1 To $numLines
- $line = $aLines[$i]
- $line = _trim($line)
- If $line = "" Then
- continueloop
- EndIf
- $iSpaceFromRight = _StringInStrRight($line, " ")
- $origName = StringTrimLeft($line, $iSpaceFromRight)
- $type = StringLeft($line, $iSpaceFromRight-1)
- If(StringMid($origName,1,1) = "*") Then
- $origName = StringTrimLeft($origName,1)
- $type = $type & "*"
- EndIf
- If(StringRight($origName, 1)) = ";" Then
- $origName = StringTrimRight($origName, 1)
- EndIf
- $name = $origName
- If(StringMid($name, 1, 1)) = "_" Then
- $name = StringTrimLeft($name, 1)
- EndIf
- $nameUpper = StringUpper(StringMid($name, 1, 1)) & StringTrimLeft($name, 1)
- ;MsgBox(0,0,"name: '" & $nameUpper &"'" &@CRLF & "type: '" & $type & "'")
- $outGet &= $type & " get" & $nameUpper & "() const { return " & $origName & "; }" & @CRLF
- If($origName <> $name) Then
- $outSet &= "void set" & $nameUpper & "(" & $type & " " & $name & ") { " & $origName & " = " & $name & "; }" & @CRLF
- Else
- $outSet &= "void set" & $nameUpper & "(" & $type & " " & $name & ") { this->" & $origName & " = " & $name & "; }" & @CRLF
- EndIf
- Next
- $outGet = StringTrimRight($outGet, 2)
- $outSet = StringTrimRight($outSet, 2)
- GUICtrlSetData($edit2, $outGet & @CRLF & @CRLF & $outSet)
- EndFunc
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- Exit
- Case $go
- _go()
- Case $copy
- ClipPut(GUICtrlRead($edit2))
- EndSwitch
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement