VS2005 VC6添加文件描述、guard宏

vs2005

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module myproject

    Sub FileGuard()
        'DESCRIPTION: File Guard

        Dim GuardName As String
        Dim DocSel As EnvDTE.TextSelection

        DocSel = DTE.ActiveDocument.Selection

        GuardName = DTE.ActiveDocument.Name
        GuardName = GuardName.Replace(".", "_")
        GuardName = "__" + GuardName + "__"
        GuardName = GuardName.ToUpper()

        DocSel.StartOfDocument()
        DocSel.Text = "#ifndef " + GuardName
        DocSel.NewLine()
        DocSel.Text = "#define " + GuardName
        DocSel.NewLine()
        DocSel.NewLine()
        DocSel.EndOfDocument()
        DocSel.NewLine()
        DocSel.NewLine()
        DocSel.Text = "#endif // " + GuardName
    End Sub

    Sub DescFile()
        'DESCRIPTION: File description
        Dim DocName As String
        Dim Timestamp As String
        Dim DocSel As EnvDTE.TextSelection

        DocSel = DTE.ActiveDocument.Selection

        DocName = DTE.ActiveDocument.Name
        Timestamp = System.DateTime.Now.ToString()
        Timestamp = Timestamp.Replace("-", "/")

        DocSel.StartOfDocument()
        DocSel.Text = "//============================================================================="
        DocSel.NewLine()
        DocSel.Text = "/**"
        DocSel.NewLine()
        DocSel.Text = " *  @file   " + DocName
        DocSel.NewLine()
        DocSel.Text = "*"
        DocSel.NewLine()
        DocSel.Text = "*  " + DocName + " v 1.0 " + TimeString + " zhoubo created"
        DocSel.NewLine()
        DocSel.Text = "*"
        DocSel.NewLine()
        DocSel.Text = "*  @author zhoubo <lovebzhou@gmail.com>"
        DocSel.NewLine()
        DocSel.Text = "*/"
        DocSel.NewLine()
        DocSel.StartOfLine()
        DocSel.Text = "//============================================================================="
        DocSel.NewLine()
        DocSel.NewLine()
    End Sub

    Sub DescFileSimple()
        'DESCRIPTION: Simple File Description
        Dim DocName As String
        Dim Timestamp As String
        Dim DocSel As EnvDTE.TextSelection

        DocSel = DTE.ActiveDocument.Selection

        DocName = DTE.ActiveDocument.Name
        Timestamp = System.DateTime.Now.ToString()
        Timestamp = Timestamp.Replace("-", "/")

        DocSel.StartOfDocument()
        DocSel.Text = "// " + DocName + "  " + Timestamp
        DocSel.NewLine()
        DocSel.Text = "// zhoubo <lovebzhou@gmail.com>"
        DocSel.NewLine()
        DocSel.NewLine()
    End Sub

    Sub DescFileAndGuard()
        FileGuard()
        DescFileSimple()
    End Sub

    Sub DescClass()
        Dim DocSel As EnvDTE.TextSelection
        Dim ClassName As String
        DocSel = DTE.ActiveDocument.Selection

        ClassName = Trim(DocSel.Text)
        ClassName = ClassName.Substring(6)

        DocSel.LineUp()
        DocSel.NewLine()
        DocSel.Text = "/**"
        DocSel.NewLine()
        DocSel.Text = " * @class " + ClassName
        DocSel.Text = "*"
        DocSel.NewLine()
        DocSel.Text = "* @brief "
        DocSel.NewLine()
        DocSel.Text = "*/"
    End Sub

    Sub DescFunction()
        Dim DocSel As EnvDTE.TextSelection

        DocSel = DTE.ActiveDocument.Selection

        DocSel.LineUp()
        DocSel.NewLine()
        DocSel.Text = "/**"
        DocSel.NewLine()
        DocSel.Text = " * @param "
        DocSel.NewLine()
        DocSel.Text = "*"
        DocSel.NewLine()
        DocSel.Text = "* @return "
        DocSel.NewLine()
        DocSel.Text = "*/"
    End Sub

End Module



VC6

'------------------------------------------------------------------------------
'FILE DESCRIPTION: New Macro File
'------------------------------------------------------------------------------
Sub FileDescription()
'DESCRIPTION: File description
    TimeString = CStr(Now)
    TimeString = Replace(TimeString, "-", "/")
    Descr =    "//=============================================================================" + vbLF + _
            "/**" + vbLF + _
            "*  @file   " + ActiveDocument.Name + vbLF + _
            "*" + vbLF + _
            "*  " + ActiveDocument.Name + ", v 1.0 " + TimeString + " zhoubo created" + vbLF + _
            "*" + vbLF + _
            "*  @author zhoubo <lovebzhou@gmail.com>" + vbLF + _
            "*/" + vbLF + _
            "//=============================================================================" + vbLF + vbLF
    ActiveDocument.Selection = Descr

End Sub

Sub SimpleFileDescription()
'DESCRIPTION: Simple File Description
    TimeString = CStr(Now)
    TimeString = Replace(TimeString, "-", "/")
    Descr = "// " + ActiveDocument.Name + ", " + TimeString + vbLF + _
            "// zhoubo <lovebzhou@gmail.com>" + vbLF + vbLF
    ActiveDocument.Selection = Descr

End Sub

Sub ClassDescription    
    Descr = "/**" + vbLF + _
            " * @class " + vbLF + _
            " *" + vbLF + _
            " * @brief " + vbLF + _
            " */"
    ActiveDocument.Selection = Descr    
End Sub

Sub FunctionDescription    
    Descr = "/**" + vbLF + _
            " * @param " + vbLF + _
            " * @return " + vbLF + _
            " */"
    ActiveDocument.Selection = Descr    
End Sub

Sub FileGuard()
'DESCRIPTION: File Guard
    gMacro = UCase("__" + Replace(ActiveDocument.Name, ".", "_") + "__")
    
    Descr = "#ifndef " + gMacro + vbLF +  _
            "#define " + gMacro + vbLF + vbLF + vbLF + _
            "#endif // " + gMacro

    ActiveDocument.Selection = Descr
End Sub



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值