BEAST - Free Software Audio Synthesizer and Tracker  0.9.2
sfidl-namespace.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef _SFIDL_NAMESPACE_H__
3 #define _SFIDL_NAMESPACE_H__
4 
5 #include <stdio.h>
6 #include "sfidl-utils.hh"
7 
8 namespace Sfidl {
9 
10 /*
11  * This class is used during code generation. It generates the namespace
12  * opening and closing code.
13  */
15  protected:
16  FILE *out;
17  std::list<String> currentNamespace;
18 
19  public:
20  NamespaceHelper(FILE *outputfile);
21  ~NamespaceHelper();
22 
23  /*
24  * This method will cause the NamespaceHelper to enter the namespace the
25  * symbol is in. That means setFromSymbol("Arts::Object") will enter the
26  * namespace Arts. Since this generates code, it should only be called
27  * outside of class definitions.
28  */
29  void setFromSymbol (String symbol);
30 
31  /*
32  * This leaves all open namespaces which is useful if you want to include
33  * a file or such, or if you are at the end of a file.
34  */
35  void leaveAll();
36 
37  /*
38  * The shortest printable form of a symbol - using "Arts::Object" as
39  * example, this would be "Arts::Object", if you are in no namespace,
40  * ::Arts::Object, if you are in a different namespace, and just Object,
41  * if you are in the Arts namespace.
42  */
43  String printableForm (String symbol);
44  const char* printable_form (String symbol);
45 
46  /*
47  * Returns only the last component of the symbol (the name) cutting the
48  * namespace components
49  */
50  static String nameOf (String symbol);
51 
52  /*
53  * Returns everything but the last component of the symbol, which is
54  * the namespace (e.g. namespaceOf("Arts::Object") returns Arts, and
55  * nameOf("Arts::Object") returns Object).
56  */
57  static String namespaceOf (String symbol);
58 };
59 
60 }
61 
62 #endif /* _SFIDL_NAMESPACE_H__ */
63 
64 /* vim:set ts=8 sts=2 sw=2: */
Definition: sfidl-namespace.hh:14
The Sfidl namespace contains implementation and API of the Sfi IDL compiler.
Definition: sfidl-cbase.hh:14
STL class.
STL class.