adjust rules to what the code looks like

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24183 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-04-08 20:22:13 +00:00
parent 668e38191c
commit 4451a90fd0

View File

@ -210,10 +210,21 @@ Formatting
int a, b; // wrong int a, b; // wrong
This is especially important when initialization is done at the same This is especially important when initialization is done at the same
time: time:
string a("Lars"); string a = "Lars";
string b("Gullik"); string b = "Gullik";
-NOT- -NOT-
string a("Lars"), b("Gullik"); // wrong string a = "Lars", b = "Gullik"; // wrong
[Note that 'string a = "Lars"' is formally calling a copy constructor
on a temporary constructed from a string literal and therefore has the
potential of being more expensive then direct construction by
'string a("Lars")'. However the compiler is allowed to elide the copy
(even if it had side effects), and modern compilers typically do so.
Given these equal costs, LyX code favours the '=' idiom as it is in
line with the traditional C-style initialization, _and_ cannot be
mistaken as function declaration, _and_ reduces the level of nested
parantheses in more initializations.]
* Pointers and references * Pointers and references
char * p = "flop"; char * p = "flop";
@ -259,10 +270,7 @@ Formatting
* Naming rules for classes * Naming rules for classes
- Use descriptive but simple and short names. For stuff specific to LyX - Use descriptive but simple and short names. Do not abbreviate.
use LyX as prefix. Some modules, like mathed or spellchecker, could have
other prefixes.
[I am not so sure about the LyX prefix]
- Class names are usually capitalized, and function names lowercased. - Class names are usually capitalized, and function names lowercased.
Enums are named like Classes, values are usually in lower-case. Enums are named like Classes, values are usually in lower-case.
@ -281,14 +289,14 @@ Formatting
* Use existing structures * Use existing structures
- Use string wherever possible. LyX will someday move to Unicode, and - Use string wherever possible. LyX will someday move to Unicode, and
that will be easy if everybody uses string now. that will be easy if everybody uses string now. Unicode strings
should prefer using docstring instead of UTF-8 encoded std::string.
- Check out the filename and path tools in filetools.h - Check out the filename and path tools in filetools.h
- Check out the string tools in lstring.h, and the SubString class - Check out the string tools in lstring.h.
and the regex class.
- Use the DebugStream class to report errors and messages using - Use the LyXErr class to report errors and messages using
the lyxerr instantiation. the lyxerr instantiation.
[add description of other existing structures] [add description of other existing structures]