BEAST/BSE - Better Audio System and Sound Engine
0.8.2
|
00001 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef _SFIDL_NAMESPACE_H__ 00003 #define _SFIDL_NAMESPACE_H__ 00004 00005 #include <stdio.h> 00006 #include "sfidl-utils.hh" 00007 00008 namespace Sfidl { 00009 00010 /* 00011 * This class is used during code generation. It generates the namespace 00012 * opening and closing code. 00013 */ 00014 class NamespaceHelper { 00015 protected: 00016 FILE *out; 00017 std::list<String> currentNamespace; 00018 00019 public: 00020 NamespaceHelper(FILE *outputfile); 00021 ~NamespaceHelper(); 00022 00023 /* 00024 * This method will cause the NamespaceHelper to enter the namespace the 00025 * symbol is in. That means setFromSymbol("Arts::Object") will enter the 00026 * namespace Arts. Since this generates code, it should only be called 00027 * outside of class definitions. 00028 */ 00029 void setFromSymbol (String symbol); 00030 00031 /* 00032 * This leaves all open namespaces which is useful if you want to include 00033 * a file or such, or if you are at the end of a file. 00034 */ 00035 void leaveAll(); 00036 00037 /* 00038 * The shortest printable form of a symbol - using "Arts::Object" as 00039 * example, this would be "Arts::Object", if you are in no namespace, 00040 * ::Arts::Object, if you are in a different namespace, and just Object, 00041 * if you are in the Arts namespace. 00042 */ 00043 String printableForm (String symbol); 00044 const char* printable_form (String symbol); 00045 00046 /* 00047 * Returns only the last component of the symbol (the name) cutting the 00048 * namespace components 00049 */ 00050 static String nameOf (String symbol); 00051 00052 /* 00053 * Returns everything but the last component of the symbol, which is 00054 * the namespace (e.g. namespaceOf("Arts::Object") returns Arts, and 00055 * nameOf("Arts::Object") returns Object). 00056 */ 00057 static String namespaceOf (String symbol); 00058 }; 00059 00060 } 00061 00062 #endif /* _SFIDL_NAMESPACE_H__ */ 00063 00064 /* vim:set ts=8 sts=2 sw=2: */