Carbide. c ++ shortcut

Source: Internet
Author: User
Tags c constructor

Carbide. c ++ shortcuts

Edit related
CTRL + scroll Ctrl + scroll up and down in the editing area (scroll slider)
CTRL + ← Ctrl + → move a word forward and backward
CTRL + Shift + ↓ Ctrl + Shift + ↑ move a paragraph up and down (you can easily scroll through the function method)
CTRL + G search workspace Declaration
CTRL + Shift + G search all references
CTRL + Shift + S save all documents
CTRL + F find and replace
CTRL + J incremental search (dynamic match based on dynamic keyboard input)
CTRL + k search to replace the next
CTRL + l go to the specified row number
CTRL + Shift + F4 close all editing windows
CTRL + Shift + P match the corresponding parentheses
CTRL + Shift + x convert the selected lower case to upper case
CTRL + Shift + y convert the selected upper case to lower case
CTRL + M switch the current window between minimization and Maximization
CTRL + q define the Last edited place
CTRL + O quick outline display
CTRL + k quickly locate to the next one by referencing the selected word
CTRL + e quickly display the drop-down list of the current editer
CTRL + 'very useful functions in C/C ++ to open relevant source files or header files
CTRL + D Delete the current row
CTRL + ALT + ↓ copy the current row to the next row (copy added)
CTRL + ALT + ↓ copy the current row to the previous row (copy added)
Alt + ↓ switch the position of the current row and the following row (especially practical, you can save cutting and pasting)
Alt + ↑ the position of the current row and the previous one (same as above)

Compile and run
CTRL + B-recompile all projects.
F11-debug the current project.
CTRL + F11-run the current project.
CTRL +. And ctrl.,-Go to the next/previous project prompt. When the compiler generates a lot of compilation warnings and other information for us, this function will play a major role.
CTRL + Shift + B-switch the breakpoint status of the current row. Note: This shortcut key is only available on the debugging interface and unavailable on the Symbian development interface.
CTRL + ALT + B program editing target project

Debugging
F5-enter the current row function.
F6-execute the current row.
F8-continue execution.
CTRL + R-execute to the current row.

Refactoring
Alt + Shift + R-reconstruction of variable name letters

Read Source Code
F3-view variable Declaration
F4-view certain inheritance hierarchies
CTRL + T quickly view the class inheritance relationship

Navigation problems
F2-Focus on the editing View
Alt + Shift + w when the focus is in the editing area, the source file navigation view (outline, Navigator, C ++ project) is displayed)
CTRL + F6, CTRL + Shift + F6 switch the opened document in the editing view (similar to the Windows Alt + TLB and ALT + Shift + TBL)
CTRL + F7, CTRL + Shift + F7 switch the Global View
CTRL + F8, CTRL + Shift + F8-UI group switch. This shortcut can be used to switch the Symbian interface group and debug interface group.

 

 

Development Environment:
Compile in VC:
Step 1: Run bldmake bldfiles in/group: To generate makefile
Step 2: abld makefile vc6
Step 3: Open the project file, compile the file, and attach the file
Epoc.exe, (C:/Symbian/8.0a/s60_2nd_fp2_ SC/epoc32/release/wins/udeb/epoc.exe)

Build and compile through command line:

Step 1: bldmake bldfiles
Step 2: generate the target version
Simulator version: abld build wins (urel) udeb enters epoc.exe in the command line to start the simulator.

Target device version: abld build thumb urel (udeb). Generally, the target platform selects armi and thumb.

Step 3: Package the application
CD sis
Makesis yourproject. PKG

Devices command (Platform SDK switch)

Devices: displays the installed SDK
A. devices-setdefault @ SDK platform ID
B. Modify C:/program files/common files/Symbian/devices. xml
Symbian
6.0, 8.0 backward compatible 6.0 can run on 8.0, but 8.0 cannot run on 6.0

9.0

Carbide C ++:
F3: View Declaration
Double-click the breakpoint on the left or right-click the menu
CTRL +/: Comment, ALT +/: display the member list
CTRL + Shift + L: Show All shortcut keys
CTRL + F8: Switch debug/carbide C ++ Mode
F11: Debug F5: Step into F6: Step out F8: Resume
CTRL + B; build project
CTRL + F11: Run
CTRL + Shift + F format a piece of code
Edit code style: In the window/preferences... dialog box on the menu bar
C/C ++ code style
CTRL + D delete a row
Alt + direction key: Move the code up or down
Alt + Ctrl + direction key: copy the code to the specified direction
Alt + Shift + R: Rename after the selected class name
CTRL + Shift + x convert to uppercase
CTRL + Shift + Y to lowercase
CTRL + M: full screen switch
Leavescan:
For/R % I in (*. cpp) Do leavescan % I> leavescan.txt
T class
!, Stack space allocation)
2. No destructor (no pointer member variable)
3. Generally, the value assignment operator is not overloaded.

Class C
1. allocate memory (HEAP) on the heap)
2. inherit from cbase and use new (eleave) for memory allocation)
3. By default, the value assignment operation and copy structure are private (copying is not allowed, and references and pointers are generally used)
Reference is recommended.
4. A two-segment constructor is usually required to construct a constructor.

R class:
1. Memory is usually allocated on the stack.
2. The R class is related to the server resources. Usually close () or free () is required after use ()

It is related to system service calls. It is equivalent to a server handle,

Example: RFS-a handle to a file server session
Location: f32file. h
Link against: efsrv. Lib
Note that the header file, library efsrv. Lib, and SDK help are included.

M class
1. Used for multi-Inheritance
2. Generally, there is no implementation method for defining only class interfaces (generally pure virtual functions)
3. No data member

User: eave (INT) Throw

Void functionl ()
{
User: eave (-1); // throw-1;
}

Void function2l ()
{
Functionl ()
}

Void function3 ()
{
// Equivalent to trapd (ERR, function2l ());
Tint err;
Trap (err, function2l (); // try {function2l ();}

If (Err! = Kerrnone) // catch (tint ERR ){}
{
}
}
// New eleave overload pseudocode
New (eleave)
{
Void * P = new class ()
If (P)
{Memset (0, sizeof (p ));}
Else
{User: eave (nofreememory );}
}
// Throw an exception
User: eave (Tint)
User: eaveiferror (Tint) // It is usually used to convert the function that returns the error code to an exception and throw the function.
// Capture exceptions
Tint err;
Trap (err, leavefunctionl ());
Trapd (ERR, leavefunctionl (); // integrates the definition of the err variable
// New (eleave) Operator
1. If the memory is insufficient, an exception is thrown.
2. If the allocation is successful, initialize the memory to 0.
Wild pointer: When a pointer is declared, its value is random and it does not know where to point it,
It may point to the system code area. If the access is made at this time, the program will crash.
For example, char * PCH; // the PCH value is random.
PCH = new char; // a specific address in PCH
Delete PCH; // release the space indicated by PCH, but the value of PCH remains unchanged.
PCH = NULL; // It must be set to null, because if
// When deleting, if PCH is not set to null,
// Point to the original space
// At this time, delete will cause the second release program to crash,

// Delete null is safe.
// But delete the same address (except 0), the program will crash

// Exception capture principles
1. Exception capture consumes system resources, minimizing the use of trap and trapd.
2. We recommend that you capture and process exceptions at the entry of the Program (exception capture and processing for top-level functions)

// Stack clearing principles:
1. Immediately press the allocated memory to clear the stack
2. pushl and pop must match
3. The order in which the stack is cleared should follow the principle of "first-in-first-out ".
4. pushl (Tany * Aany) and pushl (cbase * Aclass) can be used together

Tclass * classs1 = new (eleave) tclass ();
// Cleanupstack: ushl (Tany * any)
Cleanupstack: ushl (class1 );
CClass * class2 = new (eleave) cClass ();
// Cleanupstack: ushl (cbase * Class)
Cleanupstack: ushl (class2 );
// Do something
Cleanupstack: opanddestroy (2 );

// Internal implementation of popanddestroy:
// Call Delete class to delete Class C;
// Tany deletes the Call User: free any;
5. Do not put the member variables of the class into the clear stack. You only need to release them in the class destructor; otherwise, the second release may occur,
If newl () exists, the member variables should use the newl () method.

6. For r classes, cleanupclosepushl () is generally used (),
Cleanupreleasepushl (), cleanupdeletepushl (), and other functions. after use, cleanupstack: opanddestroy ();

// Two-Segment Structure
1. Symbian stipulates that class C constructor is not allowed to have exceptions. Generally, two-segment constructor is used to construct a class C.
Cmyclass * mycls = new (eleave) cmyclass;
Cleanupstack: ushl (mycls );
Mycls-> constructl ();
// Do something
Cleanupstack: opanddestroy ();
2. We usually provide two static methods newl and newlc for Class C to construct two segments (newl is implemented through newlc)
3. If our C class provides the newl and newlc methods, we should set the constructor and constructl () Methods to private or protected.
4. The newl method is usually used to initialize the member variables of the class. newlc is usually used to initialize local variables.
5. When we inherit from a class C, we need to explicitly call the constructorl () of the base class in our constructl () method ()
(The constructl () attribute of the base class is protected)
Myclass: construcl ()
{
Myclassbase: constructl ();
}
Descriptor
| Type (4bit) | leader | data (PTR) |
The following descriptor can view the SDK

// These two are the base classes of all descriptors and cannot be instantiated.
Tdesc (base class of Descriptor cannot be modified)
TDES (base class for modifiable descriptors)

Tptr
Tptrc
Tbuf
Tbufc
Hbufc
Example:
Tptr
# If defined (_ Unicode)
Typedef tptr16 tptr;
# Else
Typedef tptr8 tptr;
# Endif

// Descriptor
// Descriptor read/write features
1. modifiable descriptor, inherited from TDES
Tbuf <n>
Tptr
2. the descriptor that cannot be modified inherits from tdesc.
Tbufc <n>
Tptrc
Hbufc

// Descriptor usage
1. Buffer descriptor, used on Stack
Tbufc <n> can be assigned a value and cannot be modified. The des () method can be used to convert it to a modifiable descriptor. In tbufc, tptr des ();
No copy () method
Tbuf <n> No DEs () method, void copy (const tdesc & ades );
You can assign values or modify values.
2 pointer descriptor, similar to a pointer that can point to a buffer description, heap descriptor, or another pointer Descriptor
Tptr can modify pointer Descriptors (can be modified and assigned values)
Tptr COPY method (which can accept any type of Descriptor ):
Void copy (const tdesc8 & ades );
A. initialize through the existing modifiable pointer Descriptor (des () method of tbufc or hbufc
B. initialize through the string buffer, tuint16 Buf [20]; tptr (BUF, 20 );
Tptrc (the pointer descriptor cannot be modified or assigned)
No copy method
Any descriptor can be used for initialization (which can point to any descriptor)
Both of them provide the Set () method to modify its point, but the Set () method does not reload
Same as that of tptr, set () has void set (tptr16 & aptr );
And void set (tuint16 * abuf, tint alength, tint amaxlength );
Set () of tptrc includes: void set (const tuint16 * abuf, tint alength );
And void set (const tdesc16 & ades );
3. Heap Descriptor
Hbufc (hbufc8, hbufc16)
You can use its static method to create a heap descriptor for allocating memory on the stack.
(Hbufc: newl (size), hbufc: newlc (size ))
The declaration of newl () and newlc () in the SDK:
Static hbufc * newl (tint amaxlength): // note that a pointer of the hbufc type is returned.
Static hbufc * newlc (tint amaxlength );
You can use the allocl () method of the tdesc class to create a heap descriptor through an existing descriptor.
In SDK: allocl () Declaration: hbufc16 * allocl () const;
Similar to tbufc <n>, the des () method is also provided to be converted to modifiable.
// Note that tbufc does not have the copy () method, but can be assigned a value. tdesc does not,
Tbuf and TDES have the copy () method. It is best to declare a tbuf
Change the descriptor. If you want to modify hbufc, use des () to obtain the modifiable description.
Character
Tbufc <50> stackbuf (_ L ("Hello Symbian! "));
Hbufc * heapbuffer = hbufc: newlc (50 );
Tint length = heapbuffer-> length (); // current length is 0
Console-> rintf (_ L ("length = % d/N"), length );

Tptr ptrheap (heapbuffer-> des ());
Ptrheap = stackbuf; // ptrheap. Copy (stackbuf );
Console-> rintf (_ L ("heapbuffer = % s/n"), heapbuffer); // note that no &
Cleanupstack: opanddestroy (); // do not forget
You can use reallocl () to dynamically increase the memory size.

Assert () Assertions
1. carrayptrseg <tTask> * itaskarray;
At (), delete () (only delete elements in the container), appendl (), insertl (),
Resetanddestroy () (delete the object indicated by the element in the container and reset it ),
Count () method
The memory of the carrayptrseg container is pointer
2. carrayfixseg <tTask> * taskarray;
The method is basically the same as carrayptrseg
The carrayfixseg container memory places the object itself
3. rarray <tTask> itaskarray;
Use the remove () method instead of Delete ()
Use itaskarray [Index] instead of itaskarray. At (INDEX)
Use remove () instead of removel ()
Insertl (const tTask & atask, tint aindex)
The order of parameters is different from that of values 1 and 2.
In the Destructor:

 

4. rpointerarray <tTask> itaskarray;
Methods are basically the same as rarray, except for the remove () method and the destructor.
Rpointerarray remove () only removes the elements in the array.
Release space pointed to by the element
Void ctaskmanagerrpointerarray: eletaskl (const tint aindex)
{
TTask * task = itaskarray [aindex];
Itaskarray. Remove (aindex );
Delete task;
}
Ctaskmanagerrpointerarray ::~ Ctaskmanagerrpointerarray ()
{
Itaskarray. resetanddestroy ();
Itaskarray. Close ();
}
Rpointerarray stores pointers.
Dynamic Array
// Carrayx
1. Store fixed-size elements
Carrayfixflat // linear structure
Carrayfixseg // linked list Structure
A dynamic array that stores fixed-size elements. Copies of objects are copied to the array.
Internal
2. store pointers (the element size is not fixed)
Carrayptrflat // linear structure
Carrayptrseg // linked list Structure
Only store pointers to dynamic arrays, and the object itself has its own memory unit,
Call resetanddestroy () before the array is destroyed ();
To delete a single element, you must first obtain the element pointer and execute
After deletion, remember to release the memory unit of the element.
// Rarray and rpointerarray
// Compared with carrayx, it is more efficient and flexible. We recommend that you use these two arrays.
Rarray: stores elements of a fixed size (usually class T or basic type)
Call the close () method when deactivating.
Rpointerarray: stores any type of pointer (Class C cannot be stored)
When deactivating the destroy, you must first call the resetanddestroy () method and then call
Close ().
// Dynamic descriptor Array
1. General descriptor Array
Cdesc16arrayflat
Cdesc16arrayseg
Copying a copy of Descriptor data to an array is safer, but it is a waste of memory.
// Pointer descriptor Array
Cptrc16array
It can accept all types of descriptors and create a tptrc internally.
Pointing to the passed Descriptor
Only copy the descriptor pointer (tptrc), which saves a lot of memory. The disadvantage is that
Security risks during data destruction or modification

Related Article

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.