8.1 Hiding code parts

An arbitrary even number of '// ...' comments may appear inside a 'BEGIN/END' code block. All the code between two of these comment lines will be skipped in the output and replaced by a single ``dotted line'' (...). This is useful for example, if you want to show the source code of a class, but don't want to bother the reader with all the private class stuff.

Recall the header file from section 2, which will be reprinted here for convenience, by using the following command: `` \sourceinput[fontname=blg, fontsize=8, listing]{ ClassDefs.h}{ ALL} ''. Notice the use of the special tag name ``ALL'', which includes a source file as a whole.

Listing 6: ClassDefs.h
// BEGIN Example1
class Example1 {
private :
  int x;                             // Integer variable
public : 
  explicit Example1(int i) : x(i) {} // The constructor
};
// END Example1

// BEGIN Example2
class Example2 {
// ...
private :
  double y;
// ...
public :
  // BEGIN Constructors
  explicit Example2(double d) : y(d) {}
  explicit Example2(int i) : y(i) {}
  explicit Example2(long l) : y(l) {}
  explicit Example2(char c) : y((unsigned int)c) {}
  // END Constructors
  void doSomething(); // do something 
};
// END Example2

In the way described until now we can include the class definition of the class ``Example2'' by issuing the command: `` \sourceinput[fontname=ul9, fontenc=T1, fontsize=7, listing, linenr, label=Example2]{ ClassDefs.h}{ Example2}''.

Listing 7: ClassDefs.h [Line 11 to 24]
class Example2 {
...
public :
  <see Listing 8>
  void doSomething(); // do something 
};

As you can see however, the private part of the class definition is replaced by the mentioned ``dotted line'' which stands for as much as ``there is some hidden code at this position in the file, but this code is not important in the actual context''.

Volker Simonis 2003-03-05