当前位置: 首页>>代码示例>>C++>>正文


C++ STLSOFT_NUM_ELEMENTS函数代码示例

本文整理汇总了C++中STLSOFT_NUM_ELEMENTS函数的典型用法代码示例。如果您正苦于以下问题:C++ STLSOFT_NUM_ELEMENTS函数的具体用法?C++ STLSOFT_NUM_ELEMENTS怎么用?C++ STLSOFT_NUM_ELEMENTS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了STLSOFT_NUM_ELEMENTS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_plain_characters

static void test_plain_characters()
{
    static char const plain_characters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`[email protected]#$%^&*()-_=+[{]}|;:\",<.>/?";

    // 1. Setup

    pantheios::be::test::reset();


    // 2. Create test data

    { for(size_t i = 0; STLSOFT_NUM_ELEMENTS(plain_characters) - 1 != i; ++i)
    {
        PAN_CHAR_T const ch = plain_characters[i];

        pantheios::log_NOTICE(PSTR("{"), pantheios::stream_character(ch), PSTR("}"));
    }}


    // 3. Verification

    pantheios::be::test::Results  results = pantheios::be::test::results();

    XTESTS_TEST(!results.empty());
    XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(plain_characters) - 1, results.size());

    { for(size_t i = 0; STLSOFT_NUM_ELEMENTS(plain_characters) - 1 != i; ++i)
    {
        PAN_CHAR_T const    ch      =   plain_characters[i];
        PAN_CHAR_T          sz[4]   =   { '{', ch, '}', '\0' };

        XTESTS_TEST_STRING_EQUAL(sz, results[i].statement);
    }}
}
开发者ID:DoraXBMC,项目名称:Pantheios,代码行数:34,代码来源:test.component.inserters.stream_character.cpp

示例2: test_1_01

static void test_1_01()
{
    // 1. Setup

    const PAN_CHAR_T  prefix[]    =   PSTR("thread: ");
    PAN_CHAR_T        tid_[21 + STLSOFT_NUM_ELEMENTS(prefix)];
    PAN_CHAR_T const*   tid         =   stlsoft::integer_to_string(&tid_[0], STLSOFT_NUM_ELEMENTS(tid_), pan_get_tid_());
    PAN_CHAR_T const* stmt        =   tid - (STLSOFT_NUM_ELEMENTS(prefix) - 1);

#ifdef PANTHEIOS_USE_WIDE_STRINGS
    ::wcsncpy(const_cast<PAN_CHAR_T*>(stmt), prefix, (STLSOFT_NUM_ELEMENTS(prefix) - 1));
#else /* ? PANTHEIOS_USE_WIDE_STRINGS */
    ::strncpy(const_cast<PAN_CHAR_T*>(stmt), prefix, (STLSOFT_NUM_ELEMENTS(prefix) - 1));
#endif /* PANTHEIOS_USE_WIDE_STRINGS */

    pantheios::be::test::reset();


    // 2. Create test data

    pantheios::log_NOTICE(pantheios::threadId);
    pantheios::log_NOTICE(prefix, pantheios::threadId);


    // 3. Verification

    pantheios::be::test::Results  results = pantheios::be::test::results();

    XTESTS_TEST(!results.empty());
    XTESTS_TEST(2 == results.size());
    XTESTS_TEST_STRING_EQUAL(tid, results[0].statement);
    XTESTS_TEST_STRING_EQUAL(stmt, results[1].statement);
}
开发者ID:rasslingcats,项目名称:calico,代码行数:33,代码来源:test.component.inserters.threadId.cpp

示例3: throw

inline winini_bundle::string_type winini_bundle::operator [](char_type const *name) const throw(std::out_of_range)
{
    static const char_type sentinel[] = FASTFORMAT_LITERAL_STRING("{5DDAADE5-5134-4734-ACB8-A6D0FA3BD0EA}-{D875F19B-8279-4c44-9517-F16366BC13E3}");

    ::SetLastError(0);

    char_type   result[1001];
    DWORD       dw = ::GetPrivateProfileString(
                                            m_iniSection.c_str()
                                        ,   name
                                        ,   sentinel
                                        ,   &result[0]
                                        ,   STLSOFT_NUM_ELEMENTS(result)
                                        ,   m_iniFileName.c_str());

    if(dw == STLSOFT_NUM_ELEMENTS(sentinel) - 1)    /* element not found */
    {
        if(0 == string_type::traits_type::compare(sentinel, result, stlsoft::minimum(size_t(dw), STLSOFT_NUM_ELEMENTS(sentinel) - 1)))
        {
            throw std::out_of_range("section/key combination does not exist in the given INI file");
        }
    }

    ::GetLastError();

    return string_type(result, dw);
}
开发者ID:JerYme,项目名称:fastformat,代码行数:27,代码来源:winini_bundle.hpp

示例4: main_

static int main_(int /* argc */, char** /* argv */)
{
#ifdef FASTFORMAT_USE_WIDE_STRINGS

#else /* ? FASTFORMAT_USE_WIDE_STRINGS */

    char const* arg0    =   "abcdefghi";
    const char  arg1[]  =            "jklmnopq";
    std::string arg2    =                    "rstuvwxyz";

    {
        char    buff[30];

        ff::sinks::c_string_sink   sink(STLSOFT_NUM_ELEMENTS(buff), &buff[0]);

        ff::write(sink, arg0);

        STLSOFT_ASSERT(9u == sink.size());

        ff::write(sink, arg1);

        STLSOFT_ASSERT(17u == sink.size());

        ff::write(sink, arg2);

        STLSOFT_ASSERT(26u == sink.size());

        STLSOFT_ASSERT(0 == ::strcmp("abcdefghijklmnopqrstuvwxyz", buff));
    }

    try
    {
        char    buff[20];

        ff::sinks::c_string_sink   sink(STLSOFT_NUM_ELEMENTS(buff), &buff[0]);

        ff::write(sink, arg0);

        STLSOFT_ASSERT(9u == sink.size());

        ff::write(sink, arg1);

        STLSOFT_ASSERT(17u == sink.size());

        ff::write(sink, arg2); // Teleport to ... 

        STLSOFT_MESSAGE_ASSERT("should never get here", 0);
    }
    catch(std::out_of_range& /* x */)
    {
        // ... here!
    }

#endif /* FASTFORMAT_USE_WIDE_STRINGS */

    return EXIT_SUCCESS;
}
开发者ID:moteus,项目名称:FastFormat,代码行数:57,代码来源:example.sink.c_string.cpp

示例5: c_str_data_a

        char const* c_str_data_a(double d)
        {
            int n = ::snprintf(&s_realBuffer[0], STLSOFT_NUM_ELEMENTS(s_realBuffer) - 1, "%G", d);

            if(n < 0)
            {
                n = STLSOFT_NUM_ELEMENTS(s_realBuffer) - 1;
            }

            s_realBuffer[n] = '\0';

            return s_realBuffer;
        }
开发者ID:brinkqiang,项目名称:fastformat,代码行数:13,代码来源:test.performance.one_pointer.cpp

示例6: internal_GetIDOfName

inline
/* static */
DISPID
object_helper::
    internal_GetIDOfName(
        object const&   o,
        LPCOLESTR methodName
    ) /* const */
    {
        DISPID      dispids[1]  =   { 0 };
        HRESULT     hr          =   internal_has_member(o, methodName, &dispids[0]);

        if(FAILED(hr))
        {
            if(DISP_E_UNKNOWNNAME == hr)
            {
#if 0
                stlsoft::exception_string_creator creator(256u);

                creator
                    .append("Unknown name: '")
                    .append(methodName)
                    .append('\'')
                    ;

                throw invocation_exception(creator.c_str(), hr);
#else /* ? 0 */
                typedef winstl::system_traits<char> traits_t;

                static const char           msg[] = "Unknown name: '";
                winstl::w2a                 a(methodName);
                stlsoft::auto_buffer<char>  buff(STLSOFT_NUM_ELEMENTS(msg) + a.size() + 1);

                traits_t::char_copy(&buff[0], msg, STLSOFT_NUM_ELEMENTS(msg) - 1);
                traits_t::char_copy(&buff[0] + (STLSOFT_NUM_ELEMENTS(msg) - 1), a, a.size());
                buff[(STLSOFT_NUM_ELEMENTS(msg) - 1) + a.size()] = '\'';
                buff[(STLSOFT_NUM_ELEMENTS(msg) - 1) + a.size() + 1] = '\0';

                STLSOFT_ASSERT(1 + ::strlen(buff.data()) == buff.size());   // Guard against changing "size()" for winstl::wide2multibyte

                throw invocation_exception(buff.data(), hr);
#endif /* 0 */
            }
            else
            {
                throw invocation_exception("GetIDsOfNames failed", hr);
            }
        }

        return dispids[0];
    }
开发者ID:synesissoftware,项目名称:VOLE,代码行数:51,代码来源:object.hpp

示例7: STLSOFT_NUM_ELEMENTS

void thread_id_t::construct_()
{
    pan_char_t          sz[21]; // This is large enough for any number up to 64-bits
    pan_char_t const*   num = stlsoft::integer_to_string(&sz[0], STLSOFT_NUM_ELEMENTS(sz), pantheios_getCurrentThreadId(), m_len);

    ::memcpy(&m_value[0], num, (m_len + 1) * sizeof(pan_char_t));
}
开发者ID:rasslingcats,项目名称:calico,代码行数:7,代码来源:threadid.cpp

示例8: test_1_01

static void test_1_01()
{
    { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(s_severities); ++i)
    {
        const int severity = s_severities[i];

        // 1. Setup

        pantheios::be::test::reset();


        // 2. Create test data

        pantheios::pantheios_logprintf(severity, PSTR("abc"));


        // 3. Verification

        pantheios::be::test::Results  results = pantheios::be::test::results();

        if(!results.empty()) // Do test here, so will work with any back-end
        {
            XTESTS_TEST(1 == results.size());
            PANTHEIOS_SEV_LEVELS_EQUAL(severity, results[0].severity);
            XTESTS_TEST_STRING_EQUAL(PSTR("abc"), results[0].statement);
        }
    }}
}
开发者ID:DoraXBMC,项目名称:Pantheios,代码行数:28,代码来源:test.component.core.pantheios_logprintf.cpp

示例9: test_1_04

static void test_1_04()
{
    // 1. Setup

    pantheios::be::test::reset();


    // 2. Create test data

    char const* argv[] =
    {
            "abc"
        ,   "def"
        ,   "ghi"
        ,   "jkl"
    };

    pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv));


    // 3. Verification

    pantheios::be::test::Results  results = pantheios::be::test::results();

    XTESTS_TEST(!results.empty());
    XTESTS_TEST(1 == results.size());
    XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc, def, ghi, jkl", results[0].statement);
}
开发者ID:DoraXBMC,项目名称:Pantheios,代码行数:28,代码来源:test.component.inserters.args.cpp

示例10: test_1_18

static void test_1_18()
{
    // 1. Setup

    pantheios::be::test::reset();


    // 2. Create test data

    char const* argv[] =
    {
            "abc"
        ,   "def ghi"
        ,   "jkl"
    };

    pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::alwaysQuoteArgs, "|"));


    // 3. Verification

    pantheios::be::test::Results  results = pantheios::be::test::results();

    XTESTS_TEST(!results.empty());
    XTESTS_TEST(1 == results.size());
    XTESTS_TEST_MULTIBYTE_STRING_EQUAL("\"abc\"|\"def ghi\"|\"jkl\"", results[0].statement);
}
开发者ID:DoraXBMC,项目名称:Pantheios,代码行数:27,代码来源:test.component.inserters.args.cpp

示例11: Invoke

STDMETHODIMP CMainDlg::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
	if(
		dispIdMember < BASE_DIPSPID || 
		dispIdMember > sPhoneJsFunc[STLSOFT_NUM_ELEMENTS(sPhoneJsFunc) - 1]._dispId
		)
	{
		return E_NOTIMPL;
	}

	// 检查参数个数
	if(pDispParams->cArgs != sPhoneJsFunc[dispIdMember - BASE_DIPSPID]._argc)
	{
		return E_INVALIDARG;
	}

	// 所有的参数都是字符串
	for(UINT i = 0; i < pDispParams->cArgs; ++i)
	{
		if((pDispParams->rgvarg[i].vt & VT_BSTR) == 0)
		{
			return E_INVALIDARG;
		}
	}

	return (this->*(sPhoneJsFunc[dispIdMember - BASE_DIPSPID]._pFuncProc))(dispIdMember, pDispParams, pVarResult);
}
开发者ID:6520874,项目名称:pcmanager,代码行数:27,代码来源:MainDlg.cpp

示例12: xcontract_lookup_violation_type_string_

static char const* xcontract_lookup_violation_type_string_(xContract_violation_type_t type, size_t* len)
{
    XCONTRACT_TYPE_STR_DECL(xContract_unexpectedCondition       ,   "unexpected condition"          );
    XCONTRACT_TYPE_STR_DECL(xContract_precondition_logic        ,   "precondition (logic)"          );
    XCONTRACT_TYPE_STR_DECL(xContract_precondition_parameters   ,   "precondition (parameters)"     );
    XCONTRACT_TYPE_STR_DECL(xContract_postcondition_returnValue ,   "postcondition (return value)"  );
    XCONTRACT_TYPE_STR_DECL(xContract_postcondition_logic       ,   "postcondition (logic)"         );
    XCONTRACT_TYPE_STR_DECL(xContract_postcondition_parameters  ,   "postcondition (parameters)"    );
    XCONTRACT_TYPE_STR_DECL(xContract_invariant_class           ,   "class invariant"               );
    XCONTRACT_TYPE_STR_DECL(xContract_invariant_global          ,   "global invariant"              );
    XCONTRACT_TYPE_STR_DECL(xContract_staticData                ,   "static data"                   );
    XCONTRACT_TYPE_STR_DECL(xContract_intermediateAssumption    ,   "global invariant"              );


    static const xContract_type_string* s_strings[] = 
    {
        XCONTRACT_TYPE_STR_ENTRY(xContract_unexpectedCondition),
        XCONTRACT_TYPE_STR_ENTRY(xContract_precondition_logic),
        XCONTRACT_TYPE_STR_ENTRY(xContract_precondition_parameters),
        XCONTRACT_TYPE_STR_ENTRY(xContract_postcondition_returnValue),
        XCONTRACT_TYPE_STR_ENTRY(xContract_postcondition_logic),
        XCONTRACT_TYPE_STR_ENTRY(xContract_postcondition_parameters),
        XCONTRACT_TYPE_STR_ENTRY(xContract_invariant_class),
        XCONTRACT_TYPE_STR_ENTRY(xContract_invariant_global),
        XCONTRACT_TYPE_STR_ENTRY(xContract_staticData),
        XCONTRACT_TYPE_STR_ENTRY(xContract_intermediateAssumption),
    };

    return xContract_lookup_type_(type, s_strings, STLSOFT_NUM_ELEMENTS(s_strings), len);
}
开发者ID:FeMTTU,项目名称:femus,代码行数:30,代码来源:xcontract.core.c

示例13: 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);
        }
    }}
}
开发者ID:wqjkdqj,项目名称:Palabos,代码行数:29,代码来源:test.unit.util.gethostname.cpp

示例14: 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]));
}
开发者ID:DoraXBMC,项目名称:Pantheios,代码行数:33,代码来源:bec.fprintf.cpp

示例15: pan_make_hostIdentity_

// TODO: This should go in a src/util/x/y.cpp file
static char* pan_make_hostIdentity_(void)
{
    pan_char_t  szHostName[1 + MAX_COMPUTERNAME_LENGTH];
    size_t      cch = pantheios_getHostName(&szHostName[0], STLSOFT_NUM_ELEMENTS(szHostName));

    switch(cch)
    {
        case    0:
        case    STLSOFT_NUM_ELEMENTS(szHostName):
            return pantheios_util_strdup_nothrow_m("<localhost>");
        default:
#ifdef PANTHEIOS_USE_WIDE_STRINGS
            return pantheios_util_strdup_nothrow_m(stlsoft::w2m(szHostName));
#else /* ? PANTHEIOS_USE_WIDE_STRINGS */
            return pantheios_util_strdup_nothrow_m(szHostName);
#endif /* PANTHEIOS_USE_WIDE_STRINGS */
    }
}
开发者ID:dlex,项目名称:pantheios,代码行数:19,代码来源:bec.WindowsSyslog.cpp


注:本文中的STLSOFT_NUM_ELEMENTS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。