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


C++ Obj::fixedFields方法代码示例

本文整理汇总了C++中Obj::fixedFields方法的典型用法代码示例。如果您正苦于以下问题:C++ Obj::fixedFields方法的具体用法?C++ Obj::fixedFields怎么用?C++ Obj::fixedFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Obj的用法示例。


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

示例1: main


//.........这里部分代码省略.........
        // TESTING USAGE EXAMPLE
        //
        // Concerns:
        //   The usage example-2 provided in the component header file must
        //   compile, link, and run on all platforms as shown.
        //
        // Plan:
        //   Incorporate usage example-2 from header into driver, remove
        //   leading comment characters, and replace 'assert' with 'ASSERT'.
        //
        // Testing:
        //   USAGE EXAMPLE
        // --------------------------------------------------------------------

        if (verbose) cout << endl << "Testing Usage Example-2" << endl
                                  << "=======================" << endl;


///Usage
///------
// This section illustrates intended use of this component.
//
///Example 1: Basic Use of 'ball::Record'
/// - - - - - - - - - - - - - - - - - - -
// The following example demonstrates how to create and set the properties of
// a 'ball::Record'.  Note that users of the 'ball' logging subsystem are not
// expected to create records directly.
//
// First we default create a 'ball::Record', 'record', and verify it has a
// default set of attributes:
//..
    ball::Record record;

    ASSERT(ball::RecordAttributes() == record.fixedFields());
    ASSERT(0                        == record.userFields().length());
//..
// Then, we set the fixed fields of the record to contain a simple message:
//..
    int                 processId = bdls::ProcessUtil::getProcessId();
    bsls::Types::Uint64 threadId  = bslmt::ThreadUtil::selfIdAsUint64();

    ball::RecordAttributes attributes(bdlt::CurrentTime::utc(), // time stamp
                                      processId,                // process id
                                      threadId,                 // thread id
                                      __FILE__,                 // filename
                                      __LINE__,                 // line number
                                      "ExampleCategory",        // category
                                      ball::Severity::e_WARN,   // severity
                                      "Simple Test Message");   // message
    record.setFixedFields(attributes);

    ASSERT(attributes == record.fixedFields());
//..
// Finally, we write the record to a stream:
//..
    bsl::ostringstream output;
    output << record << bsl::endl;
//..
    if (verbose) {
        bsl::cout << output.str() << bsl::endl;
    }

      } break;
      case 9: {
        // --------------------------------------------------------------------
        // TESTING FUNCTION numAllocatedBytes()
开发者ID:SuperV1234,项目名称:bde,代码行数:67,代码来源:ball_record.t.cpp


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