\hypertarget{class_ogre_1_1_c_preprocessor}{}\section{Ogre\+:\+:C\+Preprocessor Class Reference}
\label{class_ogre_1_1_c_preprocessor}\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}


This is a simplistic C/\+C++-\/like preprocessor.  




{\ttfamily \#include $<$Ogre\+G\+L\+S\+L\+Preprocessor.\+h$>$}

\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
typedef void($\ast$ \hyperlink{class_ogre_1_1_c_preprocessor_ad9572bfcaa1b4a3e290d6d3586664539}{Error\+Handler\+Func}) (void $\ast$i\+Data, int i\+Line, const char $\ast$i\+Error, const char $\ast$i\+Token, size\+\_\+t i\+Token\+Len)
\begin{DoxyCompactList}\small\item\em An error handler function type. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{class_ogre_1_1_c_preprocessor_a70001f3fef03cc20b5142e67702c3b3f}{C\+Preprocessor} ()
\begin{DoxyCompactList}\small\item\em Create an empty preprocessor object. \end{DoxyCompactList}\item 
virtual \hyperlink{class_ogre_1_1_c_preprocessor_a2b7c3b1a3208a27b36e87eee69464508}{$\sim$\+C\+Preprocessor} ()
\begin{DoxyCompactList}\small\item\em Destroy the preprocessor object. \end{DoxyCompactList}\item 
void \hyperlink{class_ogre_1_1_c_preprocessor_a3026667d0f447d89bcac3fd8c6007a00}{Define} (const char $\ast$i\+Macro\+Name, size\+\_\+t i\+Macro\+Name\+Len, const char $\ast$i\+Macro\+Value, size\+\_\+t i\+Macro\+Value\+Len)
\begin{DoxyCompactList}\small\item\em Define a macro without parameters. \end{DoxyCompactList}\item 
void \hyperlink{class_ogre_1_1_c_preprocessor_a70c0a271d5ea9dcf93d13f9c08318458}{Define} (const char $\ast$i\+Macro\+Name, size\+\_\+t i\+Macro\+Name\+Len, long i\+Macro\+Value)
\begin{DoxyCompactList}\small\item\em Define a numerical macro. \end{DoxyCompactList}\item 
char $\ast$ \hyperlink{class_ogre_1_1_c_preprocessor_ac9c8ca6c8013a5217275e35e9727052d}{Parse} (const char $\ast$i\+Source, size\+\_\+t i\+Length, size\+\_\+t \&o\+Length)
\begin{DoxyCompactList}\small\item\em Parse the input string and return a newly-\/allocated output string. \end{DoxyCompactList}\item 
bool \hyperlink{class_ogre_1_1_c_preprocessor_a3849848c4223928aea432f66184d541e}{Undef} (const char $\ast$i\+Macro\+Name, size\+\_\+t i\+Macro\+Name\+Len)
\begin{DoxyCompactList}\small\item\em Undefine a macro. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
void $\ast$ \hyperlink{class_ogre_1_1_c_preprocessor_a0341555997c45e9d084154c04fd83ecc}{Error\+Data}
\begin{DoxyCompactList}\small\item\em User-\/specific storage, passed to Error() \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Attributes}
\begin{DoxyCompactItemize}
\item 
static \hyperlink{class_ogre_1_1_c_preprocessor_ad9572bfcaa1b4a3e290d6d3586664539}{Error\+Handler\+Func} \hyperlink{class_ogre_1_1_c_preprocessor_ad335ac476f629eb7668c8189b21fb232}{Error\+Handler}
\begin{DoxyCompactList}\small\item\em A pointer to the preprocessor\textquotesingle{}s error handler. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
class \hyperlink{class_ogre_1_1_c_preprocessor_ae5a6f539ddabca71928dd965f2211434}{C\+Preprocessor\+::\+Macro}
\end{DoxyCompactItemize}


\subsection{Detailed Description}
This is a simplistic C/\+C++-\/like preprocessor. 

It takes an non-\/zero-\/terminated string on input and outputs a non-\/zero-\/terminated string buffer.

This preprocessor was designed specifically for \hyperlink{namespace_ogre_1_1_g_l_s_l}{G\+L\+SL} shaders, so if you want to use it for other purposes you might want to check if the feature set it provides is enough for you.

Here\textquotesingle{}s a list of supported features\+:
\begin{DoxyItemize}
\item Fast memory allocation-\/less operation (mostly).
\item Line continuation (backslash-\/newline) is swallowed.
\item Line numeration is fully preserved by inserting empty lines where required. This is crucial if, say, \hyperlink{namespace_ogre_1_1_g_l_s_l}{G\+L\+SL} compiler reports you an error with a line number.
\item {\ttfamily \#define\+:} Parametrized and non-\/parametrized macros. Invoking a macro with less arguments than it takes assignes empty values to missing arguments.
\item {\ttfamily \#undef\+:} Forget defined macros
\item {\ttfamily \#ifdef} / {\ttfamily \#ifndef} / {\ttfamily \#else} / {\ttfamily \#endif\+:} Conditional suppression of parts of code.
\item {\ttfamily \#if\+:} Supports numeric expression of any complexity, also supports the defined() pseudo-\/function. 
\end{DoxyItemize}

\subsection{Member Typedef Documentation}
\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_ad9572bfcaa1b4a3e290d6d3586664539}\label{class_ogre_1_1_c_preprocessor_ad9572bfcaa1b4a3e290d6d3586664539}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!Error\+Handler\+Func@{Error\+Handler\+Func}}
\index{Error\+Handler\+Func@{Error\+Handler\+Func}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{Error\+Handler\+Func}{ErrorHandlerFunc}}
{\footnotesize\ttfamily typedef void($\ast$ Ogre\+::\+C\+Preprocessor\+::\+Error\+Handler\+Func) (void $\ast$i\+Data, int i\+Line, const char $\ast$i\+Error, const char $\ast$i\+Token, size\+\_\+t i\+Token\+Len)}



An error handler function type. 

The default implementation just drops a note to stderr and then the parser ends, returning N\+U\+LL. 
\begin{DoxyParams}{Parameters}
{\em i\+Data} & User-\/specific pointer from the corresponding \hyperlink{class_ogre_1_1_c_preprocessor}{C\+Preprocessor} object. \\
\hline
{\em i\+Line} & The line at which the error happened. \\
\hline
{\em i\+Error} & The error string. \\
\hline
{\em i\+Token} & If not N\+U\+LL contains the erroneous token \\
\hline
{\em i\+Token\+Len} & The length of i\+Token. i\+Token is never zero-\/terminated! \\
\hline
\end{DoxyParams}


\subsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_a70001f3fef03cc20b5142e67702c3b3f}\label{class_ogre_1_1_c_preprocessor_a70001f3fef03cc20b5142e67702c3b3f}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!C\+Preprocessor@{C\+Preprocessor}}
\index{C\+Preprocessor@{C\+Preprocessor}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{C\+Preprocessor()}{CPreprocessor()}}
{\footnotesize\ttfamily Ogre\+::\+C\+Preprocessor\+::\+C\+Preprocessor (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Create an empty preprocessor object. 



References Define(), Undef(), and $\sim$\+C\+Preprocessor().

\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_a2b7c3b1a3208a27b36e87eee69464508}\label{class_ogre_1_1_c_preprocessor_a2b7c3b1a3208a27b36e87eee69464508}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!````~C\+Preprocessor@{$\sim$\+C\+Preprocessor}}
\index{````~C\+Preprocessor@{$\sim$\+C\+Preprocessor}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{$\sim$\+C\+Preprocessor()}{~CPreprocessor()}}
{\footnotesize\ttfamily virtual Ogre\+::\+C\+Preprocessor\+::$\sim$\+C\+Preprocessor (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



Destroy the preprocessor object. 



Referenced by C\+Preprocessor().



\subsection{Member Function Documentation}
\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_a3026667d0f447d89bcac3fd8c6007a00}\label{class_ogre_1_1_c_preprocessor_a3026667d0f447d89bcac3fd8c6007a00}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!Define@{Define}}
\index{Define@{Define}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{Define()}{Define()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily void Ogre\+::\+C\+Preprocessor\+::\+Define (\begin{DoxyParamCaption}\item[{const char $\ast$}]{i\+Macro\+Name,  }\item[{size\+\_\+t}]{i\+Macro\+Name\+Len,  }\item[{const char $\ast$}]{i\+Macro\+Value,  }\item[{size\+\_\+t}]{i\+Macro\+Value\+Len }\end{DoxyParamCaption})}



Define a macro without parameters. 


\begin{DoxyParams}{Parameters}
{\em i\+Macro\+Name} & The name of the defined macro \\
\hline
{\em i\+Macro\+Name\+Len} & The length of the name of the defined macro \\
\hline
{\em i\+Macro\+Value} & The value of the defined macro \\
\hline
{\em i\+Macro\+Value\+Len} & The length of the value of the defined macro \\
\hline
\end{DoxyParams}


Referenced by C\+Preprocessor().

\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_a70c0a271d5ea9dcf93d13f9c08318458}\label{class_ogre_1_1_c_preprocessor_a70c0a271d5ea9dcf93d13f9c08318458}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!Define@{Define}}
\index{Define@{Define}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{Define()}{Define()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void Ogre\+::\+C\+Preprocessor\+::\+Define (\begin{DoxyParamCaption}\item[{const char $\ast$}]{i\+Macro\+Name,  }\item[{size\+\_\+t}]{i\+Macro\+Name\+Len,  }\item[{long}]{i\+Macro\+Value }\end{DoxyParamCaption})}



Define a numerical macro. 


\begin{DoxyParams}{Parameters}
{\em i\+Macro\+Name} & The name of the defined macro \\
\hline
{\em i\+Macro\+Name\+Len} & The length of the name of the defined macro \\
\hline
{\em i\+Macro\+Value} & The value of the defined macro \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_a3849848c4223928aea432f66184d541e}\label{class_ogre_1_1_c_preprocessor_a3849848c4223928aea432f66184d541e}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!Undef@{Undef}}
\index{Undef@{Undef}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{Undef()}{Undef()}}
{\footnotesize\ttfamily bool Ogre\+::\+C\+Preprocessor\+::\+Undef (\begin{DoxyParamCaption}\item[{const char $\ast$}]{i\+Macro\+Name,  }\item[{size\+\_\+t}]{i\+Macro\+Name\+Len }\end{DoxyParamCaption})}



Undefine a macro. 


\begin{DoxyParams}{Parameters}
{\em i\+Macro\+Name} & The name of the macro to undefine \\
\hline
{\em i\+Macro\+Name\+Len} & The length of the name of the macro to undefine \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if the macro has been undefined, false if macro doesn\textquotesingle{}t exist 
\end{DoxyReturn}


Referenced by C\+Preprocessor().

\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_ac9c8ca6c8013a5217275e35e9727052d}\label{class_ogre_1_1_c_preprocessor_ac9c8ca6c8013a5217275e35e9727052d}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!Parse@{Parse}}
\index{Parse@{Parse}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{Parse()}{Parse()}}
{\footnotesize\ttfamily char$\ast$ Ogre\+::\+C\+Preprocessor\+::\+Parse (\begin{DoxyParamCaption}\item[{const char $\ast$}]{i\+Source,  }\item[{size\+\_\+t}]{i\+Length,  }\item[{size\+\_\+t \&}]{o\+Length }\end{DoxyParamCaption})}



Parse the input string and return a newly-\/allocated output string. 

\begin{DoxyNote}{Note}
The returned preprocessed string is N\+OT zero-\/terminated (just like the input string). 
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em i\+Source} & The source text \\
\hline
{\em i\+Length} & The length of the source text in characters \\
\hline
{\em o\+Length} & The length of the output string. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output from preprocessor, allocated with malloc(). The parser can actually allocate more than needed for performance reasons, but this should not be a problem unless you will want to store the returned pointer for long time in which case you might want to realloc() it. If an error has been encountered, the function returns N\+U\+LL. In some cases the function may return an unallocated address that\textquotesingle{}s {\itshape inside} the source buffer. You must free() the result string only if the returned address is not inside the source text. 
\end{DoxyReturn}


\subsection{Friends And Related Function Documentation}
\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_ae5a6f539ddabca71928dd965f2211434}\label{class_ogre_1_1_c_preprocessor_ae5a6f539ddabca71928dd965f2211434}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!C\+Preprocessor\+::\+Macro@{C\+Preprocessor\+::\+Macro}}
\index{C\+Preprocessor\+::\+Macro@{C\+Preprocessor\+::\+Macro}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{C\+Preprocessor\+::\+Macro}{CPreprocessor::Macro}}
{\footnotesize\ttfamily friend class C\+Preprocessor\+::\+Macro\hspace{0.3cm}{\ttfamily [friend]}}



\subsection{Member Data Documentation}
\mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_ad335ac476f629eb7668c8189b21fb232}\label{class_ogre_1_1_c_preprocessor_ad335ac476f629eb7668c8189b21fb232}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!Error\+Handler@{Error\+Handler}}
\index{Error\+Handler@{Error\+Handler}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{Error\+Handler}{ErrorHandler}}
{\footnotesize\ttfamily \hyperlink{class_ogre_1_1_c_preprocessor_ad9572bfcaa1b4a3e290d6d3586664539}{Error\+Handler\+Func} Ogre\+::\+C\+Preprocessor\+::\+Error\+Handler\hspace{0.3cm}{\ttfamily [static]}}



A pointer to the preprocessor\textquotesingle{}s error handler. 

You can assign the address of your own function to this variable and implement your own error handling (e.\+g. throwing an exception etc). \mbox{\Hypertarget{class_ogre_1_1_c_preprocessor_a0341555997c45e9d084154c04fd83ecc}\label{class_ogre_1_1_c_preprocessor_a0341555997c45e9d084154c04fd83ecc}} 
\index{Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}!Error\+Data@{Error\+Data}}
\index{Error\+Data@{Error\+Data}!Ogre\+::\+C\+Preprocessor@{Ogre\+::\+C\+Preprocessor}}
\subsubsection{\texorpdfstring{Error\+Data}{ErrorData}}
{\footnotesize\ttfamily void$\ast$ Ogre\+::\+C\+Preprocessor\+::\+Error\+Data}



User-\/specific storage, passed to Error() 



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
\hyperlink{_ogre_g_l_s_l_preprocessor_8h}{Ogre\+G\+L\+S\+L\+Preprocessor.\+h}\end{DoxyCompactItemize}
