本文整理汇总了C++中Options::autoAddField方法的典型用法代码示例。如果您正苦于以下问题:C++ Options::autoAddField方法的具体用法?C++ Options::autoAddField怎么用?C++ Options::autoAddField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::autoAddField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createInstance
INT32 RecordParser::createInstance(INPUT_FORMAT format,
const Options& options,
RecordParser*& parser)
{
INT32 rc = SDB_OK;
if (FORMAT_CSV == format)
{
CSVRecordParser* csvParser =
SDB_OSS_NEW CSVRecordParser(options.fieldDelimiter(),
options.stringDelimiter(),
options.dateFormat(),
options.timestampFormat(),
options.trimString(),
options.autoAddField(),
options.autoCompletion(),
options.hasHeaderLine(),
options.cast(),
options.ignoreNull(),
options.force(),
options.strictFieldNum());
if (NULL == csvParser)
{
rc = SDB_OOM;
PD_LOG(PDERROR, "failed to create CSVRecordParser object, rc=%d",
rc);
goto error;
}
if (!options.fields().empty())
{
PD_LOG(PDINFO, "fields: %s", options.fields().c_str());
if (options.verbose())
{
std::cout << "fields: " << options.fields()
<< std::endl;
}
const CHAR* str = options.fields().c_str();
INT32 len = options.fields().length();
rc = csvParser->parseFields(str, len, FALSE);
if (SDB_OK != rc)
{
std::cout << "failed to parse fields" << std::endl;
PD_LOG(PDERROR, "failed to parse fields, rc=%d", rc);
goto error;
}
if (options.verbose())
{
csvParser->printFieldsDef();
}
}
parser = csvParser;
}
else
{
SDB_ASSERT(FORMAT_JSON == format, "format must be JSON");
JSONRecordParser* jsonParser =
SDB_OSS_NEW JSONRecordParser();
if (NULL == jsonParser)
{
rc = SDB_OOM;
PD_LOG(PDERROR, "failed to create JSONRecordParser object, rc=%d",
rc);
goto error;
}
rc = jsonParser->init() ;
if( rc )
{
PD_LOG( PDERROR, "failed to call JSONRecordParser init, rc=%d",
rc ) ;
goto error ;
}
parser = jsonParser;
}
done:
return rc;
error:
goto done;
}