本文整理汇总了C++中PANTHEIOS_LITERAL_STRING函数的典型用法代码示例。如果您正苦于以下问题:C++ PANTHEIOS_LITERAL_STRING函数的具体用法?C++ PANTHEIOS_LITERAL_STRING怎么用?C++ PANTHEIOS_LITERAL_STRING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PANTHEIOS_LITERAL_STRING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pan_get_hid_
static string_t pan_get_hid_()
{
#if defined(PLATFORMSTL_OS_IS_UNIX)
PAN_CHAR_T szHostName[1001];
if(0 != ::gethostname(&szHostName[0], STLSOFT_NUM_ELEMENTS(szHostName)))
{
return PANTHEIOS_LITERAL_STRING("localhost");
}
else
{
return szHostName;
}
#elif defined(PLATFORMSTL_OS_IS_WINDOWS)
PAN_CHAR_T szHostName[1001];
DWORD cchHostName = STLSOFT_NUM_ELEMENTS(szHostName);
if(!pantheios_GetComputerName_(&szHostName[0], &cchHostName))
{
return PANTHEIOS_LITERAL_STRING("localhost");
}
else
{
return string_t(szHostName, static_cast<size_t>(cchHostName));
}
#else /* ? OS */
# error Not discriminated for platforms other than UNIX and Windows
#endif /* OS */
}
示例2: test_win_F_HIDE_TIME
static void test_win_F_HIDE_TIME()
{
const int timeFlags = 0
| 0
| PANTHEIOS_GETCURRENTTIME_F_HIDE_TIME
| 0;
pan_beutil_time_t tm(0, NULL);
size_t expected = pantheios_util_getCurrentTime(&tm, timeFlags);
PANTHEIOS_TEST_TIME( 0, timeFlags, expected, PANTHEIOS_LITERAL_STRING(""));
{ for(size_t i = 1; i < expected + 100; ++i)
{
PANTHEIOS_TEST_TIME( expected + i, timeFlags, expected, PANTHEIOS_LITERAL_STRING("*"));
}}
}
示例3: pan_slice_t
int be_fprintf_Context::rawLogEntry(
int severity4
, int /* severityX */
, const pan_slice_t (&ar)[rawLogArrayDimension]
, size_t /* cchTotal */
)
{
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(severity4 >= 0, "severity must be >= 0");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(severity4 < 16, "severity must be < 16");
// select the stream: stdout for debug/info/notice; stderr for everything else
FILE* const stm = deduce_stm_(severity4);
const PAN_CHAR_T fmt[] = PANTHEIOS_LITERAL_STRING("%.*s%.*s%.*s%.*s%.*s%.*s%.*s%.*s%.*s%.*s\n");
STLSOFT_STATIC_ASSERT(4 * rawLogArrayDimension + 2 == STLSOFT_NUM_ELEMENTS(fmt));
// fprintf the array of slices
#define PAN_BE_GET_SLICE_4_PRINTF(x) int(x.len), x.ptr
return pan_fprintf_(stm, fmt
, PAN_BE_GET_SLICE_4_PRINTF(ar[0])
, PAN_BE_GET_SLICE_4_PRINTF(ar[1])
, PAN_BE_GET_SLICE_4_PRINTF(ar[2])
, PAN_BE_GET_SLICE_4_PRINTF(ar[3])
, PAN_BE_GET_SLICE_4_PRINTF(ar[4])
, PAN_BE_GET_SLICE_4_PRINTF(ar[5])
, PAN_BE_GET_SLICE_4_PRINTF(ar[6])
, PAN_BE_GET_SLICE_4_PRINTF(ar[7])
, PAN_BE_GET_SLICE_4_PRINTF(ar[8])
, PAN_BE_GET_SLICE_4_PRINTF(ar[9]));
}
示例4: test_1_01
static void test_1_01()
{
PAN_CHAR_T hostname[1000];
const string_t hid = pan_get_hid_();
{ for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(hostname); ++i)
{
::memset(&hostname[0], 0, sizeof(hostname));
const size_t len = pantheios::getHostName(&hostname[0], i);
if(len == i)
{
// The function did not have enough space to write in, so it
// will return the length passed to it ...
XTESTS_TEST_INTEGER_EQUAL(i, len);
// ... and will not have written anything to the file
XTESTS_TEST_STRING_EQUAL(PANTHEIOS_LITERAL_STRING(""), hostname);
}
else
{
// The function had enough space, so it will return the length
// of the intended hostname ...
XTESTS_TEST_INTEGER_EQUAL(hid.size(), len);
// ... and will have written the hostname
XTESTS_TEST_STRING_EQUAL(hid, hostname);
}
}}
}
示例5: main
int main()
{
/* Must initialise Pantheios, when using from C (and there are no C++
* compilation units in the link-unit).
*
* If this is not done, undefined behaviour will ensue ...
*/
if(pantheios_init() < 0)
{
return EXIT_FAILURE;
}
else
{
int i = 123;
float f = 99.99f;
/* Log the int and the float: Output: "int=123, float=99.99"
*/
pantheios_logprintf(PANTHEIOS_SEV_INFORMATIONAL
, PANTHEIOS_LITERAL_STRING("int=%d, float=%g")
, i, f);
/* Must uninitialise Pantheios.
*
* pantheios_uninit() must be called once for each successful (>=0)
* invocation of pantheios_init().
*/
pantheios_uninit();
return EXIT_SUCCESS;
}
}
示例6: PANTHEIOS_CALL
PANTHEIOS_CALL(int) pantheios_be_speech_parseArgs(
size_t numArgs
, pan_slice_t* const args
, pan_be_speech_init_t* init
)
{
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API((NULL != args || 0 == numArgs), "argument pointer must be non-null, or number of arguments must be 0");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != init, "initialisation structure pointer may not be null");
pantheios_be_speech_getDefaultAppInit(init);
// 1. Parse the stock arguments
int res = pantheios_be_parseStockArgs(numArgs, args, &init->flags);
if(res >= 0)
{
// 2.a Parse the custom argument: "synchronous"
res = pantheios_be_parseBooleanArg(numArgs, args, PANTHEIOS_LITERAL_STRING("synchronous"), true, PANTHEIOS_BE_SPEECH_F_SYNCHRONOUS, &init->flags);
}
if(res >= 0)
{
// 2.b Parse the custom argument: "purgeBeforeSpeak"
res = pantheios_be_parseBooleanArg(numArgs, args, PANTHEIOS_LITERAL_STRING("purgeBeforeSpeak"), true, PANTHEIOS_BE_SPEECH_F_PURGE_BEFORE_SPEAK, &init->flags);
}
if(res >= 0)
{
// 2.c Parse the custom argument: "speakPunctuation"
res = pantheios_be_parseBooleanArg(numArgs, args, PANTHEIOS_LITERAL_STRING("speakPunctuation"), true, PANTHEIOS_BE_SPEECH_F_SPEAK_PUNCTUATION, &init->flags);
}
if(res >= 0)
{
// 2.d Parse the custom argument: "synchronousOnCritical"
res = pantheios_be_parseBooleanArg(numArgs, args, PANTHEIOS_LITERAL_STRING("synchronousOnCritical"), true, PANTHEIOS_BE_SPEECH_F_SYNCHRONOUS_ON_CRITICAL, &init->flags);
}
return res;
}
示例7: main
int main()
{
int i = pantheios_init();
if(i >= 0)
{
/* 1. Using the Pantheios API macro PANTHEIOS_MAKE_EXTENDED_SEVERITY() */
pantheios_logprintf(PANTHEIOS_MAKE_EXTENDED_SEVERITY(PANTHEIOS_SEV_NOTICE, 10), PANTHEIOS_LITERAL_STRING("hello"));
/* 2 (a). In your code, you'd define your own, most succinct, symbol, e.g. ACME_XSEV(sev, xi28) */
#define ACME_XSEV(sev, xi28) PANTHEIOS_MAKE_EXTENDED_SEVERITY(PANTHEIOS_SEV_ ## sev, xi28)
/* 2 (b). and use it as follows */
pantheios_logprintf(ACME_XSEV(NOTICE, 10), PANTHEIOS_LITERAL_STRING("hello"));
pantheios_uninit();
}
return EXIT_SUCCESS;
}
示例8: main
int main()
{
/* Must initialise Pantheios, when using from C (and there are no C++
* compilation units in the link-unit).
*
* If this is not done, undefined behaviour will ensue ...
*/
if(pantheios_init() < 0)
{
return EXIT_FAILURE;
}
else
{
pantheios_logputs(PANTHEIOS_SEV_DEBUG, PANTHEIOS_LITERAL_STRING("debug"));
pantheios_logputs(PANTHEIOS_SEV_INFORMATIONAL, PANTHEIOS_LITERAL_STRING("info"));
pantheios_logputs(PANTHEIOS_SEV_NOTICE, PANTHEIOS_LITERAL_STRING("notice"));
pantheios_logputs(PANTHEIOS_SEV_WARNING, PANTHEIOS_LITERAL_STRING("warn"));
pantheios_be_file_setFilePath(PANTHEIOS_LITERAL_STRING("file-1.log"), PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BE_FILE_F_TRUNCATE, 1);
pantheios_logputs(PANTHEIOS_SEV_ERROR, PANTHEIOS_LITERAL_STRING("error"));
pantheios_logputs(PANTHEIOS_SEV_CRITICAL, PANTHEIOS_LITERAL_STRING("critical"));
pantheios_logputs(PANTHEIOS_SEV_ALERT, PANTHEIOS_LITERAL_STRING("alert"));
pantheios_logputs(PANTHEIOS_SEV_EMERGENCY, PANTHEIOS_LITERAL_STRING("emergency"));
pantheios_be_file_setFilePath(PANTHEIOS_LITERAL_STRING("file-5.log"), 0, 0, 5);
/* Must uninitialise Pantheios.
*
* pantheios_uninit() must be called once for each successful (>=0)
* invocation of pantheios_init().
*/
pantheios_uninit();
return EXIT_SUCCESS;
}
}
示例9: PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL
int be_fprintf_Context::rawLogEntry(
int severity4
, int /* severityX */
, pan_char_t const* entry
, size_t cchEntry
)
{
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(severity4 >= 0, "severity must be >= 0");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(severity4 < 16, "severity must be < 16");
// select the stream: stdout for debug/info/notice; stderr for everything else
FILE* const stm = deduce_stm_(severity4);
// output
return pan_fprintf_(stm, PANTHEIOS_LITERAL_STRING("%.*s\n"), int(cchEntry), entry);
}
示例10: PANTHEIOS_CALL
PANTHEIOS_CALL(PAN_CHAR_T const*) pantheios_fe_getProcessIdentity(void* token)
{
STLSOFT_SUPPRESS_UNUSED(token);
if(0 == s_feInitValue)
{
XTESTS_FAIL_WITH_QUALIFIER("front-end process identity interrogation", "front-end has not yet been initialised");
}
else if(1 != s_feInitValue)
{
XTESTS_FAIL_WITH_QUALIFIER("front-end process identity interrogation", "front-end has been uninitialised");
}
else if(0 != s_beInitValue)
{
XTESTS_FAIL_WITH_QUALIFIER("front-end process identity interrogation", "back-end has already been initialised");
}
return PANTHEIOS_LITERAL_STRING("test.component.core.initialisation_sequence");
}
示例11: test_1_01
static void test_1_01();
static void test_1_02();
static void test_1_03();
static void test_1_04();
static void test_1_05();
static void test_1_06();
static void test_1_07();
static void test_1_08();
static void test_1_09();
/* /////////////////////////////////////////////////////////////////////////
* Globals
*/
PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.component.custom_severity");
int main(int argc, char** argv)
{
int retCode = EXIT_SUCCESS;
int verbosity = 2;
XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
if(XTESTS_START_RUNNER("test.component.custom_severity", verbosity))
{
XTESTS_RUN_CASE(test_1_01);
XTESTS_RUN_CASE(test_1_02);
XTESTS_RUN_CASE(test_1_03);
XTESTS_RUN_CASE(test_1_04);
XTESTS_RUN_CASE(test_1_05);
示例12: PANTHEIOS_CALL
PANTHEIOS_CALL(int) pantheios_be_WindowsSyslog_parseArgs(
size_t numArgs
, pan_slice_t* const args
, pan_be_WindowsSyslog_init_t* init
)
{
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API((NULL != args || 0 == numArgs), "argument pointer must be non-null, or number of arguments must be 0");
PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != init, "initialisation structure pointer may not be null");
pantheios_be_WindowsSyslog_getDefaultAppInit(init);
// 1. Parse the stock arguments
int res = pantheios_be_parseStockArgs(numArgs, args, &init->flags);
if(res >= 0)
{
pan_slice_t address;
pan_slice_t port;
pan_slice_t facility;
// 2.a Parse the custom argument: "address"
res = pantheios_be_parseStringArg(numArgs, args, PANTHEIOS_LITERAL_STRING("address"), &address);
if(res > 0)
{
if(address.len > sizeof(init->hostNameBuff) - 1)
{
res = PANTHEIOS_BE_INIT_RC_ARGUMENT_TOO_LONG;
}
else
{
::memcpy(&init->hostNameBuff[0], address.ptr, sizeof(pan_char_t) * STLSOFT_NUM_ELEMENTS(init->hostNameBuff));
init->hostNameBuff[address.len] = '\0';
init->hostName = &init->hostNameBuff[0];
init->addrSize = 0;
}
}
if(res >= 0)
{
// 2.b Parse the custom argument: "port"
res = pantheios_be_parseStringArg(numArgs, args, PANTHEIOS_LITERAL_STRING("port"), &port);
if(res > 0)
{
char sz[21];
int portNum;
::memcpy(&sz[0], port.ptr, stlsoft::minimum(port.len, sizeof(pan_char_t) * STLSOFT_NUM_ELEMENTS(sz) - 1));
sz[stlsoft::minimum(port.len, STLSOFT_NUM_ELEMENTS(sz) - 1)] = '\0';
portNum = ::atoi(sz);
if( portNum > 0 &&
portNum < 65536)
{
init->port = static_cast<pan_uint16_t>(portNum);
}
else
{
res = PANTHEIOS_BE_INIT_RC_ARGUMENT_OUT_OF_RANGE;
}
}
}
if(res >= 0)
{
// 2.b Parse the custom argument: "facility"
res = pantheios_be_parseStringArg(numArgs, args, PANTHEIOS_LITERAL_STRING("facility"), &facility);
if(res > 0)
{
char sz[21];
int facilityNum;
::memcpy(&sz[0], facility.ptr, stlsoft::minimum(facility.len, sizeof(pan_char_t) * STLSOFT_NUM_ELEMENTS(sz) - 1));
sz[stlsoft::minimum(facility.len, STLSOFT_NUM_ELEMENTS(sz) - 1)] = '\0';
facilityNum = ::atoi(sz);
if( facilityNum >= 0 &&
facilityNum < 24)
{
init->facility = static_cast<pan_uint8_t>(facilityNum);
}
else
{
res = PANTHEIOS_BE_INIT_RC_ARGUMENT_OUT_OF_RANGE;
}
}
}
}
if(res >= 0)
{
// 2.d Parse the custom argument: "useStderr"
res = pantheios_be_parseBooleanArg(numArgs, args, PANTHEIOS_LITERAL_STRING("useStderr"), false, PANTHEIOS_BE_WINDOWSSYSLOG_F_PERROR, &init->flags);
}
if(res >= 0)
//.........这里部分代码省略.........
示例13: defined
#elif defined(PLATFORMSTL_OS_IS_WINDOWS)
# include <pantheios/backends/bec.WindowsSyslog.h>
#else /* ? OS */
# error Operating system not discriminated
#endif /* OS */
/* Standard C header files */
#include <stdlib.h> /* for exit codes */
/* /////////////////////////////////////////////////////////////////////////
* globals
*/
/* Define the stock front-end process identity, so that it links when using
* fe.N, fe.simple, etc. */
const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("example.c.N");
pan_fe_N_t PAN_FE_N_SEVERITY_CEILINGS[] =
{
{ 1, PANTHEIOS_SEV_NOTICE } /* Filters out everything below 'notice' */
, { 2, PANTHEIOS_SEV_DEBUG } /* Allows all severities */
, { 3, PANTHEIOS_SEV_ERROR } /* Allows only 'error', 'critical', 'alert', 'emergency' */
, { 0, PANTHEIOS_SEV_NOTICE } /* Terminates the array; sets the default ceiling to 'notice' */
};
pan_be_N_t PAN_BE_N_BACKEND_LIST[] =
{
PANTHEIOS_BE_N_STDFORM_ENTRY(1, pantheios_be_file, 0)
, PANTHEIOS_BE_N_STDFORM_ENTRY(2, pantheios_be_fprintf, 0)
, PANTHEIOS_BE_N_STDFORM_ENTRY(3, pantheios_be_null, 0)
#if defined(PLATFORMSTL_OS_IS_UNIX)
示例14: PANTHEIOS_SEV_LEVELS_EQUAL
/* Standard C Header Files */
#include <stdlib.h> // for exit codes
#include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
/* /////////////////////////////////////////////////////////////////////////
* Macros
*/
#define PANTHEIOS_SEV_LEVELS_EQUAL(x, y) XTESTS_TEST_INTEGER_EQUAL(static_cast<int>(x), static_cast<int>(y))
/* /////////////////////////////////////////////////////////////////////////
* Globals
*/
PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.unit.levels.dynamic_initialisation");
/* ////////////////////////////////////////////////////////////////////// */
const int debug = ::pantheios::debug;
const int informational = ::pantheios::informational;
const int notice = ::pantheios::notice;
const int warning = ::pantheios::warning;
const int error = ::pantheios::error;
const int critical = ::pantheios::critical;
const int alert = ::pantheios::alert;
const int emergency = ::pantheios::emergency;
DynamicInit::DynamicInit()
: debug (::pantheios::debug)
, informational (::pantheios::informational)
示例15: PANTHEIOS_TEST_TIME
* typedefs
*/
typedef std::basic_string<PAN_CHAR_T> string_t;
/* /////////////////////////////////////////////////////////////////////////
* macros
*/
#define PANTHEIOS_TEST_TIME(buffSize, flags, result, pattern) test_time(__FILE__, __LINE__, buffSize, flags, result, pattern)
/* /////////////////////////////////////////////////////////////////////////
* globals
*/
PANTHEIOS_EXTERN_C const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.unit.util.getcurrenttime");
/* /////////////////////////////////////////////////////////////////////////
* forward declarations
*/
static int test_time(char const* file, int line, size_t cchBuff, int flags, size_t expectedResult, PAN_CHAR_T const* pattern);
static string_t translate_pattern(PAN_CHAR_T const* pattern);
static void test_unix_0();
static void test_unix_F_USE_SYSTEM_TIME();
static void test_unix_F_HIDE_DATE();
static void test_unix_F_HIDE_TIME();
#if defined(PLATFORMSTL_OS_IS_WINDOWS)
static void test_win_0();
static void test_win_F_USE_SYSTEM_TIME();