edelib 1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

Macros
edelib macros

## Macros

#define | E_LOG_DOMAIN ((char*)0)
#define | E_DEBUG(...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_DEBUG, __VA_ARGS__)
#define | E_WARNING(...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_WARNING, __VA_ARGS__)
#define | E_FATAL(...) edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_FATAL, __VA_ARGS__)
#define | E_ASSERT(expr)
#define | E_STRLOC __FILE__ ":" _E_STRLOC_STRINGIFY(__LINE__)
#define | E_LIKELY(expr) (expr)
#define | E_UNLIKELY(expr) (expr)
#define | E_RETURN_IF_FAIL(expr)
#define | E_RETURN_VAL_IF_FAIL(expr, val)
#define | E_DIR_SEPARATOR '/'
#define | E_DIR_SEPARATOR_STR "/"
#define | EDE_APPLICATION_WITH_NLS_PATH(name, path)
#define | EDE_CONSOLE_APPLICATION_WITH_NLS_PATH(name, path) EDELIB_NS_PREPEND(nls_support_init(name, path)
#define | EDE_APPLICATION(name) EDE_APPLICATION_WITH_NLS_PATH(name, "dummy_path")
#define | EDE_CONSOLE_APPLICATION(name) EDE_CONSOLE_APPLICATION_WITH_NLS_PATH(name, "dummy_path")
#define | EDELIB_NS edelib
#define | EDELIB_NS_USE using namespace EDELIB_NS;
#define | EDELIB_NS_USING(n) using EDELIB_NS::n;
#define | EDELIB_NS_USING_AS(old_name, new_name) typedef EDELIB_NS::old_name new_name;
#define | EDELIB_NS_PREPEND(n) EDELIB_NS::n
#define | EDELIB_NS_USING_LIST(n, list) EDELIB_FOR_EACH(n, list)
#define | E_DISABLE_CLASS_COPY(klass)
#define | E_CLASS_GLOBAL_DECLARE(klass) static klass* global(void);
#define | E_CLASS_GLOBAL_IMPLEMENT(klass)
#define | E_CLASS_GLOBAL_EXPLICIT_DECLARE(klass)
#define | E_CLASS_GLOBAL_EXPLICIT_IMPLEMENT(klass)

## Detailed Description

## Macro Definition Documentation

#define E_ASSERT | ( |  | expr | ) |

Value:
do { \
if(!(expr)) \
edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_FATAL, "Assertion failed: \"%s\" in %s (%d), function: \"%s\"\n", \
#expr, __FILE__, __LINE__, _E_FUNCTION_NAME); \
} while(0);

Check if expression evaluates to false, in which case it will abort program, outputing offending expression, file name and line number. If platform supports, it will try to output short stack content.

Referenced by list< EdbusData >::clear(), list< EdbusData >::erase(), and EdbusContainer< EdbusData >::unhook().

#define E_CLASS_GLOBAL_DECLARE | ( |  | klass | ) | static klass* global(void);

Declare members to access single class instance. These classes has global() member and will always return one class instance. This macro us placed in class declaration.

E_CLASS_GLOBAL_DECLARE and E_CLASS_GLOBAL_IMPLEMENT will create object on stack. Object will be created when global() was called for the first time, and will be destroyed when program quits.

#define E_CLASS_GLOBAL_EXPLICIT_DECLARE | ( |  | klass | ) |

Value:
static void init(void); \
static void shutdown(void); \
static bool inited(void); \
static klass* global(void);

Much the same as E_CLASS_GLOBAL_DECLARE, except object is allocated on heap. Unlike it, this macro will provide init() and shutdown() members so class instance can be explicitly created and destroyed. If shutdown() wasn't called at the end of the program, allocated memory will not be freed.

If init() wasn't called before global(), assertion will pop up.

#define E_CLASS_GLOBAL_EXPLICIT_IMPLEMENT | ( |  | klass | ) |

Value:
klass* klass##_instance = NULL; \
\
void klass::init(void) { \
if(!klass##_instance) \
klass##_instance = new klass(); \
} \
\
void klass::shutdown(void) { \
delete klass##_instance; \
klass##_instance = NULL; \
} \
\
bool klass::inited(void) { \
return (klass##_instance != NULL); \
} \
\
klass* klass::global(void) { \
E_ASSERT(klass##_instance != NULL && "Did you run init() first?"); \
return klass##_instance; \
}

Implement needed ingredients for E_CLASS_GLOBAL_EXPLICIT_DECLARE. Goes where class code is implemented.

#define E_CLASS_GLOBAL_IMPLEMENT | ( |  | klass | ) |

Value:
klass* klass::global(void) { \
static klass obj; \
return &obj; \
}

Implement needed ingredients to allow this class has only one instance. Should be placed in class implementation.

#define E_DEBUG | ( |  | ... | ) | edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_DEBUG, __VA_ARGS__)

Should be used for output debug information in stderr.

#define E_DIR_SEPARATOR '/'

Platfom specific directory separator as single character

#define E_DIR_SEPARATOR_STR "/"

Platfom specific directory separator as static string

#define E_DISABLE_CLASS_COPY | ( |  | klass | ) |

Value:
klass(const klass&); \
klass& operator=(klass&);

Disable class copying facility. Should be placed in private section of class declaration.

#define E_FATAL | ( |  | ... | ) | edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_FATAL, __VA_ARGS__)

Display error and call abort().

#define E_LIKELY | ( |  | expr | ) | (expr)

E_LIKELY and E_UNLIKELY macros give a hint to compiler about expected results. Gcc can use these information for optimizations. These macros are inspired with G_LIKELY and G_UNLIKELY from glib.

Note
  E_LIKELY(expr) is not the same as !E_UNLIKELY(expr).

#define E_LOG_DOMAIN ((char*)0)

This macro should be set during compilation phase. It will name logging domain showing to whom log output belongs.

#define E_RETURN_IF_FAIL | ( |  | expr | ) |

Value:
do { \
if E_LIKELY(expr) { } \
else { \
E_WARNING(E_STRLOC ": Condition '%s' failed\n", #expr); \
return; \
} \
} while(0)

E_RETURN_IF_FAIL is used for precondition and postcondition checks. When given expression fails, macro will return from current function, outputting information how condition failed.

#define E_RETURN_VAL_IF_FAIL | ( |  | expr,
|  |  | val
| ) |  |

Value:
do { \
if E_LIKELY(expr) { } \
else { \
E_WARNING(E_STRLOC ": Condition '%s' failed\n", #expr); \
return (val); \
} \
} while(0)

Check if expression evaluates to the true (same as E_RETURN_IF_FAIL), but return user specified value if expression fails.

#define E_STRLOC __FILE__ ":" _E_STRLOC_STRINGIFY(__LINE__)

Stringify current location with file name and line number.

#define E_UNLIKELY | ( |  | expr | ) | (expr)

See Also
  E_LIKELY

#define E_WARNING | ( |  | ... | ) | edelib_log(E_LOG_DOMAIN, EDELIB_ERROR_MESSAGE_WARNING, __VA_ARGS__)

Should be use for output warnings in stderr.

#define EDE_APPLICATION | ( |  | name | ) | EDE_APPLICATION_WITH_NLS_PATH(name, "dummy_path")

Initialize common EDE code with application name. This macro uses PREFIX value to setup correct path for localization data, which means the header (Ede.h) should be included after PREFIX definition.

#define EDE_APPLICATION_WITH_NLS_PATH | ( |  | name,
|  |  | path
| ) |  |

Value:
extern int FL_NORMAL_SIZE; \
FL_NORMAL_SIZE = 12; \
EDELIB_NS_PREPEND(ApplicationBootstrap) __ede_application_bootstrap(name, path)

Initialize common EDE code with application name (must be binary name) and full path to locale directory.

#define EDE_CONSOLE_APPLICATION | ( |  | name | ) | EDE_CONSOLE_APPLICATION_WITH_NLS_PATH(name, "dummy_path")

Same as EDE_APPLICATION but is intended for console applications.

#define EDE_CONSOLE_APPLICATION_WITH_NLS_PATH | ( |  | name,
|  |  | path
| ) |  | EDELIB_NS_PREPEND(nls_support_init(name, path)

Same as EDE_APPLICATION_WITH_NLS_PATH but only for console applications.

#define EDELIB_NS edelib

This is a name of the main namespace edelib uses.

#define EDELIB_NS_PREPEND | ( |  | n | ) | EDELIB_NS::n

Prepend default edelib namespace to the given identifier.

#define EDELIB_NS_USE using namespace EDELIB_NS;

This macro expands on using namespace edelib; or any other name used as the main edelib namespace name. This macro is also the preferred to use than above expression in case if namespace support was disabled.

On other hand, globally including everything from edelib namespace is not preferred either; via this way all edelib symbols will be known, causing possible name collisions. Alternative to this is to explicitly include desired names via EDELIB_NS_USING.

Note
  Please note how all EDELIB_NS_* must not be ended with semicolon! Semicolon is already present in the macro and this is the only exception for edelib macros.

#define EDELIB_NS_USING | ( |  | n | ) | using EDELIB_NS::n;

Bring this name to the global namespace. This is the preferred way since you explicitly add desired name to the global namespace.

#define EDELIB_NS_USING_AS | ( |  | old_name,
|  |  | new_name
| ) |  | typedef EDELIB_NS::old_name new_name;

Redefine the name from edelib namespace to the global one. In the case of possible name collisions when edelib name is introduced globally, this macro should be used to rename it.

#define EDELIB_NS_USING_LIST | ( |  | n,
|  |  | list
| ) |  | EDELIB_FOR_EACH(n, list)

Import given list of names, by using EDELIB_NS_USING on each, like:

EDELIB_NS_USING_LIST(3, (String, List, foreign_callback_add))

Notice given number; it should always match list size.