Hppslice:c++ Declaration and implementation of the separation program

Source: Internet
Author: User

Software Name: Hppslice
Version: 1.0
Date: 2014-11-06
Flying fox
Function:
Implements separation of implementations and declarations in C + + header files. Sometimes for rapid development, debugging, code implementation and declarations are often put together.
Such as:
Class test{
int Test ()
{
....
}
};
When we have finished debugging a class or program, in order to publish the compiled. lib or. dll also need to separate the implementation so that the separate head file out.
or in order to reduce the subsequent compilation time, we do not want the header file contains a large implementation file, so we need to separate the implementation code.
It would be a lot of trouble if it was done by hand. So I developed the tool to automate the operation.


How to use:
1, for each class, if you want to detach some or all of the methods inside the class, you need to label the previous line of the class declaration:///@slice, the next line at the end of the class tagged:///@~, there can be no blank line between
such as: (The label is a single row, the label and the declaration of the class can not have a blank line)
@slice

Class test{

...

};

///@~
2. For each method that wishes to be detached, add a label on a single line on the method name://@sl, there is no space between the lines
3, run the program, enter the corresponding command and parameters
4. Commands and Parameters:
command line/console parameters:
-B {Dir/filename}|dir/* restores files under the specified file or specified folder, you can use a wildcard character
-S {dir/filename}|dir/* separates files under the specified file or specified folder, you can use a wildcard character


Precautions:
1, because there is no format checking function, so if the use of improper format will result in separation failure, if the separation failure can be restored by the recovery instructions
2,////@sl applicable functions have more stringent restrictions, require the format as follows to use//@sl tags:
@[ret]@[email protected] (param) @{impl}
@: Represents any combination of spaces and comments, [] means optional, ret can only be a single type, such as: int, but can not be composite such as: const int, so when used to pay attention, otherwise it may cause damage to the source code.

If you find a problem with the separation code, you can recover the source file by restoring command-B


Duration: 2 days

Summarize:

Thought it would be simple when you first conceived the program. actually otherwise The main work is as follows:

1, the idea is to separate all the implementation code, but later, considering that the user may not want to separate all the code, and then added a label. As a result, the user's autonomy is greater, and the resolution becomes easier.

2, began to ignore the quotation marks and comments, resulting in the failure of resolution, when the consideration of the quotation marks and comments, the development of the difficulty has an essential improvement. Because you want to skip all comments and quotes without parsing them. The thought of preprocessing all comments directly, but doing so would outweigh the loss, because good annotations are important and cannot and should not be handled.

3, the beginning of the implementation of the time did not consider the resolution to separate, directly mixed together, resulting in procedural logic becomes complex and difficult to understand, the bug has increased. After several attempts, the interface that is now defined is used as the final implementation interface. (I've considered defining a file-parsing class to aid implementation, but it didn't, because it was difficult to completely encapsulate and mask the operation of the input file). The last modification not only reduces the amount of code, but also makes the logic of the program simple and straightforward.

4, in the development of the best is the first to think good interface, the main logic to achieve, and then implement the interface, so that the interface design can be early detection is reasonable. If it is unreasonable, it is not very difficult to reconstruct. Of course, for the knowledge or details that do not know, may have to do in advance feasibility analysis, such as the details can be realized first, in case the final only to find that the details can not be realized, then the cost of the reconstruction will be huge! Therefore, there is a trade-off problem, specific analysis of concrete problems, everything depends on the scene!


SOURCE Link


Hppslice:c++ Declaration and implementation of the separation program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.