Menu

#513 Improve AddToExtension function to be able to select attributes

Undefined
fixed
None
Undefined
2019-09-29
2017-05-26
bluehazzard
No

This patch allows Project::AddToExtension() to select nodes by attributes and clone existing nodes.
The normal behaviour does not change. The API changed to return a result (-1 on fail, 0 on success)

example xml code:

<debugger3>
    <remote_debugging>
        <options conn_type="0">
            <sub_conn baudrate="4400" />
        </options>
    <options conn_type="4" />
    </remote_debugging>
</debugger3>

usage example:
Set the attribute "baudrate" of the subnode sub_conn to "32000".
All nodes have to exist:

debugger3/remote_debugging/options:conn_type=0/sub_conn:baudrate=32000

result:

<debugger3>
    <remote_debugging>
        <options conn_type="0">
            <sub_conn baudrate="32000" />
        </options>
    <options conn_type="4" />
    </remote_debugging>
</debugger3>

If one node or attribute does not exist add a "+" before the node/attribute name:

debugger3/remote_debugging/options:conn_type=0/sub_conn:+interface=COM1

result:

<debugger3>
    <remote_debugging>
        <options conn_type="0">
            <sub_conn remote="lala" interface="COM1" />
        </options>
        <options conn_type="4" />
    </remote_debugging>
</debugger3>

If you want to clone a subnode append a # before the node name (only the node name gets cloned, not the node

debugger3/remote_debugging/options:conn_type=0/#sub_conn:+interface=COM2

result:

<debugger3>
    <remote_debugging>
        <options conn_type="0">
            <sub_conn remote="lala" interface="COM1" />
            <sub_conn interface="COM2" />
        </options>
        <options conn_type="4" />
    </remote_debugging>
</debugger3>
1 Attachments

Discussion

  • bluehazzard

    bluehazzard - 2017-05-26

    I can not add a test code because there is no possibility to read XML code from squirrel

     
  • bluehazzard

    bluehazzard - 2017-05-26

    There is a additional feature: The project gets marked as changed when you change something, because else it would not be possible to save the project after the xml got changed...

     
  • Teodor Petrov

    Teodor Petrov - 2017-05-27

    Is #512 duplicate of this ticket?

     
  • bluehazzard

    bluehazzard - 2017-05-28

    Is #512 duplicate of this ticket?

    it is a part of ticket #512. Ticket #512 consists of modifying the parameters of the debugger plugin. As i mentoined in the forum thread the debugger overwrites the xml saveings on project save, so this needs to be fixed also. This part allows to modify the different settings on the xml part (for ex. modifying settings for every target, what was not possible with the old implementation). Missing is the part where the debugger settings get overwritten by the debugger plugin. I still whait for some response on this in the forum thread: http://forums.codeblocks.org/index.php/topic,16852.msg149433.html#msg149433

     
  • Teodor Petrov

    Teodor Petrov - 2017-05-28

    Why have you changed the function to return int instead of make it return bool?

     
  • bluehazzard

    bluehazzard - 2017-05-28

    There should be more return codes:, i forget them in this patch
    0 -> All ok
    -1 -> We have not found the node and we don't force the add , so this fails
    -2 -> The right Attribute has not been found and we are not allowed to add it. We fail
    -3 -> Something wrong happened...
    X -> It is possible to extend the function without changing the api...

    I also fixed some code formating errors in this patch..

     
  • Teodor Petrov

    Teodor Petrov - 2017-05-28

    Oh, this is unacceptable. Use an enum.
    C++11 provides strong typed enums that have a type which marks how much memory will be occupied (uint32_t should be enough as storage)!

     
  • bluehazzard

    bluehazzard - 2017-05-31

    any naming convention for the enum?

     
  • Teodor Petrov

    Teodor Petrov - 2019-09-29

    I think [r11857] makes this patch obsolete. What do you think?

     

    Related

    Commit: [r11857]

  • bluehazzard

    bluehazzard - 2019-09-29
    • status: open --> fixed
    • assigned_to: Teodor Petrov
     
  • bluehazzard

    bluehazzard - 2019-09-29

    implemented in [r11857] by fuscated

     

    Related

    Commit: [r11857]


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.