1 #LyX 1.6.7 created this file. For more info see http://www.lyx.org/
6 \use_default_options true
11 \font_typewriter default
12 \font_default_family default
19 \paperfontsize default
28 \paperorientation portrait
31 \paragraph_separation indent
33 \quotes_language english
36 \paperpagestyle default
37 \listings_params "basicstyle={\footnotesize}"
38 \tracking_changes false
48 \begin_inset Newline newline
51 Rules and Recommendations
55 Rules for the code in LyX
59 \begin_layout Plain Layout
60 Updated from the C++STYLE distributed with the GNU C++ Standard.
68 \begin_layout Standard
69 The aim of this file is to serve as a guide for the developers, to aid us
70 to get clean and uniform code.
71 This document is incomplete.
72 We really like to have new developers joining the LyX Project.
73 However, we have had problems in the past with developers leaving the project
74 and their contributed code in a far from perfect state.
75 Most of this happened before we really became aware of these issues, but
76 still, we don't want it to happen again.
77 So we have put together some guidelines and rules for the developers.
84 \begin_layout Standard
85 These guidelines should save us a lot of work while cleaning up the code
86 and help us to have quality code.
87 LyX has been haunted by problems coming from unfinished projects by people
88 who have left the team.
89 Those problems will hopefully disappear if the code is easy to hand over
91 In general, if you want to contribute to the main source, we expect at
96 the most important rule first: KISS (Keep It Simple Stupid), always use
97 a simple implementation in favor of a more complicated one.
98 This eases maintenance a lot.
101 \begin_layout Itemize
102 write good C++ code: Readable, well commented and taking advantage of the
104 Follow the formatting guidelines.
108 \begin_layout Itemize
109 adapt the code to the structures already existing in LyX, or in the case
110 that you have better ideas, discuss them on the developer's list before
114 \begin_layout Itemize
115 take advantage of the C++ standard library.
116 Especially don't use custom containers when a standard container is usable;
117 learn to use the algorithms and functors in the standard library.
120 \begin_layout Itemize
121 be aware of exceptions and write exception safe code.
125 \begin_layout Itemize
126 document all variables, methods, functions, classes etc.
127 We are using the source documentation program doxygen, a program that handles
128 javadoc syntax, to document sources.
129 You can download doxygen from: http://www.stack.nl/~dimitri/doxygen/
132 \begin_layout Itemize
133 we have certain code constructs that we try to follow.
137 \begin_layout Section
141 \begin_layout Standard
142 It is implicitly understood that all patches contributed to The LyX Project
143 is under the Gnu General Public License, version 2 or later.
144 If you have a problem with that, don't contribute code.
145 Also please don't just pop up out of the blue with a huge patch (or small)
146 that changes something substantial in LyX.
147 Always discuss your ideas with the developers on the developer's mailing
149 When you create the patch, please use "diff -up" since we find that a lot
150 easier to read than the other diff formats.
151 Also please do not send patches that implements or fixes several different
152 things; several patches is a much better option.
153 We also require you to provide a commit message entry with every patch,
154 this describes in detail what the patch is doing.
158 \begin_layout Section
162 \begin_layout Standard
163 We have several guidelines on code constructs, some of these exist to make
164 the code faster, others to make the code clearer.
165 Yet others exist to allow us to take advantage of the strong type checking
170 \begin_layout Itemize
171 Declaration of variables should wait as long as possible.
172 The rule is: "Don't declare it until you need it." In C++ there are a lot
173 of user defined types, and these can very often be expensive to initialize.
174 This rule connects to the next rule too.
178 \begin_layout Itemize
179 Declare the variable as const if you don't need to change it.
180 This applies to POD types like int as well as classes.
184 \begin_layout Itemize
185 Make the scope of a variable as small as possible.
188 \begin_layout Itemize
189 Make good use of namespaces.
190 Prefer anonymous namespaces to declaring "static" for file scope.
193 \begin_layout Itemize
194 Prefer preincrement to postincrement whenever possible.
197 \begin_layout Itemize
198 Preincrement has potential of being faster than postincrement.
199 Just think about the obvious implementations of pre/post-increment.
200 This rule applies to decrement too.
203 \begin_layout Itemize
208 \begin_layout Standard
209 \begin_inset listings
210 lstparams "basicstyle={\footnotesize},language={C++}"
214 \begin_layout Plain Layout
219 \begin_layout Plain Layout
229 \begin_layout Standard
233 \begin_layout Standard
234 \begin_inset listings
238 \begin_layout Plain Layout
240 T++; // not used in LyX
243 \begin_layout Plain Layout
245 U--;// not used in LyX
254 \begin_layout Itemize
255 Try to minimize evaluation of the same code over and over.
256 This is aimed especially at loops.
258 \begin_inset Newline newline
265 \begin_layout Standard
266 \begin_inset listings
270 \begin_layout Plain Layout
272 Container::iterator end = large.end();
275 \begin_layout Plain Layout
277 for (Container::iterator it = large.begin(); it != end; ++it) {
280 \begin_layout Plain Layout
285 \begin_layout Plain Layout
295 \begin_layout Standard
299 \begin_layout Standard
300 \begin_inset listings
304 \begin_layout Plain Layout
306 for (Container::iterator it = large.begin(); it != large.end(); ++it) {
309 \begin_layout Plain Layout
314 \begin_layout Plain Layout
325 \begin_layout Itemize
326 For functions and methods that return a non-POD type
330 \begin_layout Plain Layout
336 T, return T const instead.
337 This gives better type checking, and will give a compiler warning when
338 temporaries are used wrongly.
342 \begin_layout Standard
346 \begin_layout Standard
347 \begin_inset listings
351 \begin_layout Plain Layout
361 \begin_layout Standard
365 \begin_layout Standard
366 \begin_inset listings
370 \begin_layout Plain Layout
381 \begin_layout Itemize
382 Avoid using the default cases in switch statements unless you have too.
383 Use the correct type for the switch expression and let the compiler ensure
384 that all cases are exhausted.
387 \begin_layout Itemize
388 \begin_inset listings
392 \begin_layout Plain Layout
397 \begin_layout Plain Layout
402 \begin_layout Plain Layout
407 \begin_layout Plain Layout
412 \begin_layout Plain Layout
416 \begin_layout Plain Layout
421 \begin_layout Plain Layout
425 \begin_layout Plain Layout
430 \begin_layout Plain Layout
435 \begin_layout Plain Layout
440 \begin_layout Plain Layout
445 \begin_layout Plain Layout
450 \begin_layout Plain Layout
455 \begin_layout Plain Layout
457 // not needed and would shadow a wrong use of Foo
460 \begin_layout Plain Layout
465 \begin_layout Plain Layout
475 \begin_layout Section
479 \begin_layout Standard
480 Be aware of the presence of exceptions.
481 One important thing to realize is that you often do not have to use throw,
482 try or catch to be exception safe.
483 Let's look at the different types of exceptions safety: (These are taken
484 from Herb Sutter's book[ExC++]
487 \begin_layout Enumerate
488 Basic guarantee: Even in the presence of exceptions thrown by T or other
489 exceptions, Stack objects don't leak resources.
490 Note that this also implies that the container will be destructible and
491 usable even if an exception is thrown while performing some container operation.
492 However, if an exception is thrown, the container will be in a consistent,
493 but not necessarily predictable, state.
494 Containers that support the basic guarantee can work safely in some settings.
498 \begin_layout Enumerate
499 Strong guarantee: If an operation terminates because of an exception, program
500 state will remain unchanged.
501 This always implies commit-or-rollback semantics, including that no references
502 or iterators into the container be invalidated if an operation fails.
503 For example, if a Stack client calls Top and then attempts a Push that
504 fails because of an exception, then the state of the Stack object must
505 be unchanged and the reference returned from the prior call to Top must
507 For more information on these guarantees, see Dave Abrahams's documentation
508 of the SGI exception-safe standard library adaption at: http://www.stlport.org/do
509 c/exception_safety.html Probably the most interesting point here is that
510 when you implement the basic guarantee, the strong guarantee often comes
512 For example, in our Stack implementation, almost everything we did was
513 needed to satisfy just the basic guarantee -- and what's presented above
514 very nearly satisfies the strong guarantee, with little of no extra work.
515 Not half bad, considering all the trouble we went to.
516 In addition to these two guarantees, there is one more guarantee that certain
517 functions must provide in order to make overall exception safety possible:
520 \begin_layout Enumerate
521 No throw guarantee: The function will not emit an exception under any circumstan
523 Overall exception safety isn't possible unless certain functions are guaranteed
525 In particular, we've seen that this is true for destructors; later in this
526 miniseries, we'll see that it's also needed in certain helper functions,
530 \begin_layout Standard
531 For all cases where we might be able to write exception safe functions without
532 using try, throw or catch we should do so.
533 In particular we should look over all destructors to ensure that they are
534 as exception safe as possible.
537 \begin_layout Section
541 \begin_layout Itemize
542 Only one declaration on each line.
546 \begin_layout Standard
550 \begin_layout Standard
551 \begin_inset listings
555 \begin_layout Plain Layout
560 \begin_layout Plain Layout
570 \begin_layout Standard
574 \begin_layout Standard
575 \begin_inset listings
579 \begin_layout Plain Layout
581 int a,b; // not used in LyX
589 \begin_layout Standard
590 This is especially important when initialization is done at the same time:
593 \begin_layout Standard
597 \begin_layout Standard
598 \begin_inset listings
602 \begin_layout Plain Layout
607 \begin_layout Plain Layout
617 \begin_layout Standard
621 \begin_layout Standard
622 \begin_inset listings
626 \begin_layout Plain Layout
628 string a = "Lars", b = "Gullik"; // not used in LyX
636 \begin_layout Standard
637 [Note that 'string a = "Lars"' is formally calling a copy constructor on
638 a temporary constructed from a string literal and therefore has the potential
639 of being more expensive then direct construction by 'string a("Lars")'.
640 However the compiler is allowed to elide the copy (even if it had side
641 effects), and modern compilers typically do so.
642 Given these equal costs, LyX code favours the '=' idiom as it is in line
643 with the traditional C-style initialization, _and_ cannot be mistaken as
644 function declaration, _and_ reduces the level of nested parantheses in
645 more initializations.]
649 \begin_layout Itemize
650 Pointers and references:
654 \begin_layout Standard
658 \begin_layout Standard
659 \begin_inset listings
663 \begin_layout Plain Layout
668 \begin_layout Plain Layout
678 \begin_layout Standard
682 \begin_layout Standard
683 \begin_inset listings
687 \begin_layout Plain Layout
689 char *p = "flop"; // not used in LyX
692 \begin_layout Plain Layout
694 char &c = *p; // not used in LyX
702 \begin_layout Standard
703 Some time ago we had a huge discussion on this subject and after convincing
704 argumentation from Asger this is what we decided.
705 Also note that we will have:
708 \begin_layout Standard
709 \begin_inset listings
713 \begin_layout Plain Layout
723 \begin_layout Standard
727 \begin_layout Standard
728 \begin_inset listings
732 \begin_layout Plain Layout
734 const char * p; // not used in LyX
743 \begin_layout Itemize
744 Operator names and parentheses
748 \begin_layout Standard
749 \begin_inset listings
753 \begin_layout Plain Layout
763 \begin_layout Standard
767 \begin_layout Standard
768 \begin_inset listings
772 \begin_layout Plain Layout
774 operator == (type) // not used in LyX
782 \begin_layout Standard
783 The == is part of the function name, separating it makes the declaration
784 look like an expression.
788 \begin_layout Itemize
789 Function names and parentheses
793 \begin_layout Standard
794 \begin_inset listings
798 \begin_layout Plain Layout
808 \begin_layout Standard
812 \begin_layout Standard
813 \begin_inset listings
817 \begin_layout Plain Layout
819 void mangle () // not used in LyX
828 \begin_layout Itemize
833 \begin_layout Standard
834 \begin_inset listings
838 \begin_layout Plain Layout
843 \begin_layout Plain Layout
848 \begin_layout Plain Layout
853 \begin_layout Plain Layout
858 \begin_layout Plain Layout
868 \begin_layout Standard
872 \begin_layout Standard
873 \begin_inset listings
877 \begin_layout Plain Layout
879 enum { one = 1, two = 2, three 3 }; // not used in LyX
887 \begin_layout Standard
891 \begin_layout Standard
892 \begin_inset listings
896 \begin_layout Plain Layout
901 \begin_layout Plain Layout
906 \begin_layout Plain Layout
911 \begin_layout Plain Layout
916 \begin_layout Plain Layout
927 \begin_layout Itemize
932 \begin_layout Standard
933 Using a plain 0 is always correct and least effort to type.
937 \begin_layout Standard
938 \begin_inset listings
942 \begin_layout Plain Layout
952 \begin_layout Standard
956 \begin_layout Standard
957 \begin_inset listings
961 \begin_layout Plain Layout
963 void * p = NULL; // not used in LyX
971 \begin_layout Standard
975 \begin_layout Standard
976 \begin_inset listings
980 \begin_layout Plain Layout
984 0'; // not used in LyX
992 \begin_layout Standard
996 \begin_layout Standard
997 \begin_inset listings
1001 \begin_layout Plain Layout
1003 void * p = 42 - 7 * 6; // not used in LyX
1011 \begin_layout Standard
1012 Note: As an exception, imported third party code as well as code interfacing
1013 the "native" APIs (src/support/os_*) can use NULL.
1017 \begin_layout Itemize
1018 Naming rules for classes
1022 \begin_layout Itemize
1023 Use descriptive but simple and short names.
1027 \begin_layout Itemize
1028 Class names are usually capitalized, and function names lowercased.
1031 \begin_layout Itemize
1032 Enums are named like Classes, values are usually in lower-case.
1035 \begin_layout Itemize
1036 Public API is camel-case ('void setAFlagToAValue(bool)')
1039 \begin_layout Itemize
1040 Members variables are underscored ('enable_this_feature_flag_') with a final
1044 \begin_layout Itemize
1045 Private/protected functions are also camel-case
1048 \begin_layout Itemize
1049 New types are capitalized, so this goes for typedefs, classes, structs and
1054 \begin_layout Itemize
1059 \begin_layout Itemize
1060 Adapt the formatting of your code to the one used in the other parts of
1062 In case there is different formatting for the same construct, use the one
1067 \begin_layout Itemize
1068 Use existing structures
1072 \begin_layout Itemize
1073 Use string wherever possible.
1074 LyX will someday move to Unicode, and that will be easy if everybody uses
1076 Unicode strings should prefer using docstring instead of UTF-8 encoded
1080 \begin_layout Itemize
1081 Check out the filename and path tools in filetools.h
1084 \begin_layout Itemize
1085 Check out the string tools in lstring.h.
1088 \begin_layout Itemize
1089 Use the LyXErr class to report errors and messages using the lyxerr instantiatio
1091 [add description of other existing structures]
1095 \begin_layout Itemize
1100 \begin_layout Itemize
1101 Use this order for the access sections of your class: public, protected,
1103 The public section is interesting for every user of the class.
1104 The private section is only of interest for the implementors of the class
1106 [Obviously not true since this is for developers, and we do not want one
1107 developer only to be able to read and understand the implementation of
1112 \begin_layout Itemize
1113 Avoid declaring global objects in the declaration file of the class.
1114 If the same variable is used for all objects, use a static member.
1117 \begin_layout Itemize
1118 Avoid global or static variables.
1122 \begin_layout Itemize
1127 \begin_layout Standard
1128 If you create a new file, the top of the file should look something like
1132 \begin_layout Standard
1133 \begin_inset listings
1137 \begin_layout Plain Layout
1142 \begin_layout Plain Layout
1149 \begin_layout Plain Layout
1151 * This file is part of LyX, the document processor.
1154 \begin_layout Plain Layout
1156 * Licence details can be found in the file COPYING.
1159 \begin_layout Plain Layout
1164 \begin_layout Plain Layout
1171 \begin_layout Plain Layout
1176 \begin_layout Plain Layout
1178 * Full author contact details are available in file CREDITS
1181 \begin_layout Plain Layout
1192 \begin_layout Itemize
1197 \begin_layout Itemize
1198 The documentation is generated from the header files.
1201 \begin_layout Itemize
1202 You document for the other developers, not for yourself.
1205 \begin_layout Itemize
1206 You should document what the function does, not the implementation.
1210 \begin_layout Itemize
1211 in the .cpp files you document the implementation.
1215 \begin_layout Itemize
1216 Single line description (///), multiple lines description (/** ...
1217 */) see the doxygen webpage referenced above
1221 \begin_layout Section
1222 Naming rules for Lyx User Functions (LFUNs)
1225 \begin_layout Standard
1226 Here is the set of rules to apply when a new command name is introduced:
1229 \begin_layout Enumerate
1230 Use the object.event order.
1231 That is, use `word-forward' instead of`forward-word'.
1234 \begin_layout Enumerate
1235 Don't introduce an alias for an already named object.
1239 \begin_layout Enumerate
1240 Forward movement or focus is called `forward' (not `right').
1243 \begin_layout Enumerate
1244 Backward movement or focus is called `backward' (not `left').
1247 \begin_layout Enumerate
1248 Upward movement of focus is called `up'.
1251 \begin_layout Enumerate
1252 Downward movement is called `down'.
1255 \begin_layout Enumerate
1256 The begin of an object is called `begin' (not `start').
1259 \begin_layout Enumerate
1260 The end of an object is called `end'.
1263 \begin_layout Section
1264 How to create class interfaces
1267 \begin_layout Standard
1268 (a.k.a How Non-Member Functions Improve Encapsulation)
1271 \begin_layout Standard
1272 I recently read an article by Scott Meyers in , where he makes a strong
1273 case on how non-member functions makes classes more encapsulated, not less.
1274 Just skipping to the core of this provides us with the following algorithm
1275 for deciding what kind of function to add to a class interface:
1278 \begin_layout Itemize
1279 We need to add a function f to the class C's API.
1283 \begin_layout Standard
1284 \begin_inset listings
1288 \begin_layout Plain Layout
1290 if (f needs to be virtual)
1293 \begin_layout Plain Layout
1295 make f a member function of C;
1298 \begin_layout Plain Layout
1300 else if (f is operator>> or operator<<) {
1303 \begin_layout Plain Layout
1305 make f a non-member function;
1308 \begin_layout Plain Layout
1310 if (f needs access to non-public members of C)
1313 \begin_layout Plain Layout
1315 make f a friend of C;
1318 \begin_layout Plain Layout
1320 } else if (f needs type conversions on its left-most argument) {
1323 \begin_layout Plain Layout
1325 make f a non-member function;
1328 \begin_layout Plain Layout
1330 if (f needs access to non-public members of C)
1333 \begin_layout Plain Layout
1335 make f a friend of C;
1338 \begin_layout Plain Layout
1340 } else if (f can be implemented via C's public interface)
1343 \begin_layout Plain Layout
1345 make f a non-member function;
1348 \begin_layout Plain Layout
1353 \begin_layout Plain Layout
1355 make f a member function of C;
1364 \begin_layout Chapter
1368 \begin_layout Standard
1369 These are some rules for effective C++ programming.
1370 These are taken from Scott Meyers
1371 \begin_inset CommandInset citation
1377 , and are presented in their short form.
1378 These are not all the rules Meyers presents, only the most important of
1380 LyX does not yet follow these rules, but they should be the goal.
1383 \begin_layout Itemize
1384 use const and inline instead of #define
1387 \begin_layout Itemize
1388 use the same form in corresponding calls to new and delete, i.e.
1389 write delete[] obj; if new obj[n]; was used to create the object and write
1390 delete obj; if you wrote new obj; Notice strings should be std::string's
1391 instead of char *'s.
1394 \begin_layout Itemize
1395 define a default constructor, copy constructor and an assignment operator
1396 for all classes with dynamically allocated memory that are not made noncopyable
1399 \begin_layout Itemize
1400 do not define default constructor, copy constructor and an assignment operator
1401 if the compiler generated one would do the same
1404 \begin_layout Itemize
1405 make destructors virtual in base classes and only there
1408 \begin_layout Itemize
1409 assign to all data members in operator=()
1412 \begin_layout Itemize
1413 strive for class interfaces that are complete and minimal
1416 \begin_layout Itemize
1417 differentiate among member functions, global functions and friend functions
1420 \begin_layout Itemize
1421 avoid data members in the public interface
1424 \begin_layout Itemize
1425 use const whenever possible
1428 \begin_layout Itemize
1429 pass and return objects by reference instead of by value
1432 \begin_layout Itemize
1433 choose carefully between function overloading and parameter defaulting
1436 \begin_layout Itemize
1437 never return a reference to a local object or a dereferenced pointer initialized
1438 by new within the function
1441 \begin_layout Itemize
1442 use enums for integral constants
1445 \begin_layout Itemize
1446 minimize compilation dependencies between files
1449 \begin_layout Itemize
1450 pay attention to compiler warnings
1453 \begin_layout Itemize
1454 differentiate between inheritance of interface and inheritance of implementation
1457 \begin_layout Itemize
1458 differentiate between inheritance and templates
1461 \begin_layout Itemize
1462 ensure that global objects are initialized before they are used
1465 \begin_layout Itemize
1466 avoid conditions to 'if' and 'while' that span more than a line
1469 \begin_layout Chapter
1474 \begin_layout Itemize
1475 And one of mine: (Lgb)
1479 \begin_layout Itemize
1480 when swiching on enums, refrain from using "default:" if possible
1484 \begin_layout Itemize
1485 And one of mine: (Andre')
1489 \begin_layout Itemize
1490 try to implement your class in a way that the automatically generated copy
1491 constructor and copy assignment work out-of-the box
1494 \begin_layout Itemize
1495 I don't have problems with using boost in the implementation _if and only
1496 if_ it provides actual benefits over less intrusive alternatives.
1497 I do have a problem with needlessly sprinkling 'boost::' over interfaces,
1498 especially if it does not add any value.
1502 \begin_layout Standard
1503 Given that there seems to be an unconditional "typedef unsigned int quint32;"
1504 in qglobal.h I don't think there's any platform supported by current LyX
1505 that could not use 'unsigned int' (and an static assert in some implementation
1506 file for the unlikely case some ILP64 zombie raises its ugly head again.
1507 And if that happens, using <cstdint> would still be a better choice...)
1510 \begin_layout Standard
1511 The idea is to create something that's not compilable as soon as the condition
1513 There are lots of possibilities to achieve this, some examples follow:
1516 \begin_layout Standard
1517 In C++0x there's a "built-in":
1520 \begin_layout Standard
1521 \begin_inset listings
1525 \begin_layout Plain Layout
1527 static_assert(sizeof(int) == 4, "Funny platform")
1535 \begin_layout Standard
1536 until then on namespace scope:
1539 \begin_layout Standard
1540 \begin_inset listings
1544 \begin_layout Plain Layout
1546 #include <boost/static_assert.hpp> BOOST_STATIC_ASSERT(sizeof(int) == 4)
1554 \begin_layout Standard
1558 \begin_layout Standard
1559 \begin_inset listings
1563 \begin_layout Plain Layout
1565 template<bool Condition> struct static_assert_helper;
1568 \begin_layout Plain Layout
1570 template <> struct static_assert_helper<true> {};
1573 \begin_layout Plain Layout
1575 enum { dummy = sizeof(static_assert_helper<sizeof(int) == 4>)};
1583 \begin_layout Standard
1584 or somewhat brutish without templates, in any function:
1587 \begin_layout Standard
1588 \begin_inset listings
1592 \begin_layout Plain Layout
1594 const int d = sizeof(int) - 4;
1597 \begin_layout Plain Layout
1602 \begin_layout Plain Layout
1607 \begin_layout Plain Layout
1612 \begin_layout Plain Layout
1617 \begin_layout Plain Layout
1627 \begin_layout Standard
1628 Any of them in a .cpp file will break compilation as soon as sizeof(int)
1630 Personally I prefer something like the third version (or the first, if
1631 using C++0x is allowed).
1636 \begin_layout Itemize
1637 And one of mine: (vfr)
1641 \begin_layout Itemize
1643 \begin_inset Flex URL
1646 \begin_layout Plain Layout
1648 http://www.lyx.org/trac/changeset/35855
1657 \begin_layout Standard
1658 A dynamic_cast is necessary when:
1661 \begin_layout Itemize
1662 the object to be casted is from an external library because we can't add
1663 Qxxx::asXxxx() to Qt e.g.:
1667 \begin_layout Itemize
1668 QAbstractListModel to GuiIdListModel,
1671 \begin_layout Itemize
1672 QValidator to PathValidator,
1675 \begin_layout Itemize
1676 QWidget to TabWorkArea,
1679 \begin_layout Itemize
1680 QWidget to GuiWorkArea;
1684 \begin_layout Itemize
1685 the object is to be casted from an interface to the implementing class,
1686 because the Interface does not know by whom it is implemented:
1690 \begin_layout Itemize
1691 ProgressInterface to GuiProgress,
1694 \begin_layout Itemize
1695 Application to GuiApplication.
1699 \begin_layout Standard
1700 A dynamic_cast can be replaced by:
1703 \begin_layout Itemize
1704 already existing as***Inset() functions, e.g.:
1708 \begin_layout Itemize
1712 \begin_layout Itemize
1713 asInsetMath()->asMacro(),
1716 \begin_layout Itemize
1721 \begin_layout Itemize
1722 A static_cast when we are sure this can't go wrong, e.g.:
1726 \begin_layout Itemize
1727 we are sure that CellData::inset->clone() is an InsetTableCell,
1730 \begin_layout Itemize
1731 in cases where we explicitly check it->lyxCode().
1737 \begin_layout Bibliography
1738 \begin_inset CommandInset bibitem
1739 LatexCommand bibitem
1746 Effective C++, 50 Specific Ways to Improve Your Programs and Design.
1747 Addison-Wesley, 1992
1750 \begin_layout Bibliography
1751 \begin_inset CommandInset bibitem
1752 LatexCommand bibitem
1758 Exceptional C++: 47 engineering puzzles, programming problems, and solutions.
1762 \begin_layout Bibliography
1763 \begin_inset CommandInset bibitem
1764 LatexCommand bibitem
1769 Scott Meyers, C/C++ User's Journal (Vol.18,No.2)