Question about macros and data hiding.
I have a quick question about macros vs. data hiding.
My question is:
I have a .h file that includes the following prototypes:
void throw_TaggedEx(int iLineNum /*should be set to __LINE__*/,
exception& rEx /*any std::exception*/,
ccp ccpFile /*should be set to __FILE__*/,
ccp ClassName /*User defined*/,
ccp FuncName/*User defined*/)
{
//generates information to tag to a thrown exception
//throws a Tagged_Exception class
}
To simplify this I have 5 macros:
1) JEXC_TAG_BLOCK(ccpJExcClassName, ccpJExcFuncName) //defined as
const char* ccpJExcClassName = ccpClassName;
const char* ccpJExcFuncName = ccpFuncName;
bool bJExcInBlock = false;
2) JEXC_ENTER_ROUTE_BLOCK //defined as:
try{bJExcInBlock = true;
3) JEXC_EXIT_ROUTE_BLOCK //defined as:
}catch(std::exception& rEx){throw_RoutedEx(rEx);}
4) #define throw_Tagged(rEx) throw_TaggedEx(__LINE__,
rEx, __FILE__, ccpJExcClassName, ccpJExcFuncName)
5) #define throw_Routed(rEx) throw_RoutedEx(rEx, __FILE__, ccpJExcClassName, ccpJExcFuncName)
//throw RoutedEx is similiar to throw_TaggedEx(...)
Anyways, my problem is....
I ONLY want the macros:
JEXC_TAG_BLOCK
JEXC_ENTER_ROUTE_BLOCK
JEXC_EXIT_ROUTE_BLOCK
throw_Tagged
to be available to the user to call, in other words
throw_TaggedEx //function called by throw_Tagged
throw_RoutedEx //function called bythrow_Routed
throw_Routed //macro called by JEXC_EXIT_ROUTE_BLOCK
should not be callable by the user and should be completely data hidden (invisible).
With classes, data hiding is easy using protected/private declarations, but this is a bit tricky for me because it involves hiding function prototypes/functions/and macros.
NOTE: throw_Tagged must be a macro because it uses the __LINE__ declaration so it must be set based on its actually called line of code. It calls throw_TaggedEx as a function call. But I want only throw_Tagged to be visible and NOT throw_TaggedEx.
Does any of this make sense?
Basically I need
JEXC_TAG_BLOCK
JEXC_ENTER_ROUTE_BLOCK
JEXC_EXIT_ROUTE_BLOCK
throw_Tagged
to be available to the user
and NOT
throw_TaggedEx //function called by throw_Tagged
throw_RoutedEx //function called bythrow_Routed
throw_Routed //macro called by JEXC_EXIT_ROUTE_BLOCK
In short, how do you data hide functions/macros to limit where they can be called from?
Thanks for your help,
Jeremy

