本文整理汇总了C++中TextParser类的典型用法代码示例。如果您正苦于以下问题:C++ TextParser类的具体用法?C++ TextParser怎么用?C++ TextParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: compareLines
/*
* Determine if lines from two TextParsers containing *lineSpec are identical.
* Returns nonzero if *lineSpec line not found in both files.
*/
static int compareLines(
TextParser &parser1,
TextParser &parser2,
const char *lineSpec, // e.g., "FFT Type"
bool &match, // RETURNED, true if both parsers have the line and they match
char *lineBufOut) // RETURNED, one of the lines
{
char lineBuf[LINE_LENGTH_MAX];
parser1.setCursor(0);
parser2.setCursor(0);
if(!parser1.findLine(lineSpec, lineBuf)) {
return 1;
}
if(!parser2.findLine(lineSpec, lineBufOut)) {
return 1;
}
if(strcmp(lineBuf, lineBufOut)) {
match = false;
}
else {
match = true;
}
return 0;
}
开发者ID:JeffreyEarly,项目名称:GLNumericalModelingKit,代码行数:29,代码来源:compareFFT.cpp
示例2: IndentComment
//------------------------------------------------------------------------------
//void IndentComment(wxStringstream &gen, wxString &comment,
// const wxString &prefix)
//------------------------------------------------------------------------------
void BeginScript::IndentComment(wxString &gen, wxString &comment,
const wxString &prefix)
{
TextParser tp;
#if DBGLVL_GEN_STRING
MessageInterface::ShowMessage
(wxT("BeginScript::IndentComment() comment='%s', prefix='%s'\n"),
comment.c_str(), prefix.c_str());
#endif
StringArray textArray = tp.DecomposeBlock(comment);
UnsignedInt size = textArray.size();
if (size > 0 && textArray[0] != wxT(""))
{
for (UnsignedInt i=0; i<size; i++)
{
gen << prefix << textArray[i];
if (textArray[i].find(wxT("\n")) == comment.npos &&
textArray[i].find(wxT("\r")) == comment.npos)
{
gen << wxT("\n");
}
}
}
}
开发者ID:,项目名称:,代码行数:32,代码来源:
示例3: LoadFromText
void Sprite::LoadFromText(const char *text)
{
TextParser parser;
parser.Parse(text);
TextParser::NODE *node = NULL;
if ((node = parser.GetNode("FILETYPE")) && node->values[0] == "SPRITE")
{
if ((node = parser.GetNode("RESOURCE")))
{
_texture = static_cast<Texture*>(LE_ResourceManager.GetResourceWithRegister(node->values[0].GetCharPtr())->data);
}
if ((node = parser.GetNode("FRAMES")))
{
for (size_t i = 0; i<node->children.count(); i++)
{
TextParser::NODE *child = node->children[i];
if (child)
{
TextParser::NODE *node_rect = child->FindChild("RECT");
if (node_rect)
{
AddFrame(iRect(node_rect->values[0].ToInt(),
node_rect->values[1].ToInt(),
node_rect->values[2].ToInt(),
node_rect->values[3].ToInt()
));
}
}
}
}
}
}
开发者ID:rasidin,项目名称:LimitEngine,代码行数:32,代码来源:LE_Sprite.cpp
示例4: CNTKTextFormatReaderTestRunner
CNTKTextFormatReaderTestRunner(const string& filename,
const vector<StreamDescriptor>& streams, unsigned int maxErrors) :
m_parser(std::make_shared<CorpusDescriptor>(true), wstring(filename.begin(), filename.end()), streams, true)
{
m_parser.SetMaxAllowedErrors(maxErrors);
m_parser.SetTraceLevel(TextParser<ElemType>::TraceLevel::Info);
m_parser.SetChunkSize(SIZE_MAX);
m_parser.SetNumRetries(0);
m_parser.Initialize();
}
开发者ID:AllanYiin,项目名称:CNTK,代码行数:10,代码来源:CNTKTextFormatReaderTests.cpp
示例5: TextParser_remove
static PyObject* TextParser_remove(PyObject* self, PyObject* args)
{
PyObject* handle;
if(!PyArg_ParseTuple(args, "O", &handle))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
int ret = tp->remove();
return Py_BuildValue("i", ret);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:12,代码来源:TextParser_python_api.cpp
示例6: TextParser_currentNode
static PyObject* TextParser_currentNode(PyObject* self, PyObject* args)
{
PyObject* handle;
if(!PyArg_ParseTuple(args, "O", &handle))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
std::string value;
int ret = tp->currentNode(value);
return Py_BuildValue("is", ret, value.c_str());
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:13,代码来源:TextParser_python_api.cpp
示例7: TextParser_deleteLeaf
static PyObject* TextParser_deleteLeaf(PyObject* self, PyObject* args)
{
PyObject* handle;
const char* label;
if(!PyArg_ParseTuple(args, "Os", &handle, &label))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
int ret = tp->deleteLeaf(label);
return Py_BuildValue("i", ret);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:13,代码来源:TextParser_python_api.cpp
示例8: TextParser_write
static PyObject* TextParser_write(PyObject* self, PyObject* args)
{
const char* filename;
PyObject* handle;
if(!PyArg_ParseTuple(args, "Os", &handle, &filename))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
int ret = tp->write(filename);
return Py_BuildValue("i", ret);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:13,代码来源:TextParser_python_api.cpp
示例9: TextParser_updateValue
static PyObject* TextParser_updateValue(PyObject* self, PyObject* args)
{
PyObject* handle;
const char* label;
const char* value;
if(!PyArg_ParseTuple(args, "Oss", &handle, &label, &value))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
int ret = tp->updateValue(label, value);
return Py_BuildValue("i", ret);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:14,代码来源:TextParser_python_api.cpp
示例10: TextParser_getType
static PyObject* TextParser_getType(PyObject* self, PyObject* args)
{
PyObject* handle;
const char* label;
if(!PyArg_ParseTuple(args, "Os", &handle, &label))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
int ierr;
TextParserValueType ret = tp->getType(label, &ierr);
return Py_BuildValue("ii", ierr, ret);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:14,代码来源:TextParser_python_api.cpp
示例11: TextParser_getValue
static PyObject* TextParser_getValue(PyObject* self, PyObject* args)
{
PyObject* handle;
const char* label;
if(!PyArg_ParseTuple(args, "Os", &handle, &label))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
std::string value;
int ret = tp->getValue(label, value);
return Py_BuildValue("is", ret, value.c_str());
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:14,代码来源:TextParser_python_api.cpp
示例12: elem
// #################################################################
// TextParserでのParse
CDM::E_CDM_ERRORCODE
//cdm_FieldFileNameFormat::Read(TextParser *tp)
cdm_FieldFileNameFormat::Read(cdm_TextParser tpCntl)
{
//TP
TextParser *tp = tpCntl.getTPPtr();
if( !tp )
{
return CDM::E_CDM_ERROR_TEXTPARSER;
}
vector<string> top_label; ///< カレントの子ノードのラベル格納
tp->getNodes(top_label);
//FieldFileNameFormatタグがある
int cnt=0;
for(int i=0; i< top_label.size(); i++)
{
if( (strcasecmp(top_label[i].c_str(),"FieldFileNameFormat") == 0 ) ) cnt ++;
}
if( cnt<1 ) return CDM::E_CDM_ERROR_UNDEFINED_FIELDFILENAMEFORMAT;
vector<string> label; ///< FieldFileNameFormat子ノードのラベル格納
//FieldFileNameFormatタグへの移動
tp->changeNode("FieldFileNameFormat");
//FieldFileNameFormatの子ノードを取得
tp->getNodes(label,2);
//FieldFileNameFormatの子ノード数のループ
for(int i=0; i<label.size(); i++)
{
//FieldFileNameFormatElemのインスタンス
cdm_FieldFileNameFormatElem elem(label[i]);
//FieldFileNameFormatElemのパース
if( elem.Read(tp) )
{
//FieldFileNameFormatElemをmapに追加
AddFieldFileNameFormatElem(elem);
} else {
return CDM::E_CDM_ERROR;
}
}
return CDM::E_CDM_SUCCESS;
}
开发者ID:avr-aics-riken,项目名称:CDMlib,代码行数:51,代码来源:cdm_FieldFileNameFormat.C
示例13: IndentChildString
//------------------------------------------------------------------------------
//void IndentChildString(wxStringstream &gen, GmatCommand* cmd,
// wxString &indent, Gmat::WriteMode mode,
// const wxString &prefix, const wxString &useName,
// bool indentCommentOnly)
//------------------------------------------------------------------------------
void BeginScript::IndentChildString(wxString &gen, GmatCommand* cmd,
wxString &indent, Gmat::WriteMode mode,
const wxString &prefix,
const wxString &useName,
bool indentCommentOnly)
{
TextParser tp;
#if DBGLVL_GEN_STRING
ShowCommand(wxT(""), wxT("BeginScript::IndentChildString() cmd = "), cmd);
MessageInterface::ShowMessage
(wxT("BeginScript::IndentChildString() indent='%s', mode=%d, prefix='%s', ")
wxT("useName='%s', indentCommentOnly=%d\n"), indent.c_str(), mode, prefix.c_str(),
useName.c_str(), indentCommentOnly);
#endif
wxString cmdstr;
if (indentCommentOnly)
cmdstr = cmd->GetCommentLine();
else
cmdstr = cmd->GetGeneratingString(mode, prefix, useName);
StringArray textArray = tp.DecomposeBlock(cmdstr);
UnsignedInt size = textArray.size();
#if DBGLVL_GEN_STRING
MessageInterface::ShowMessage(wxT(" There are %d text lines\n"), size);
#endif
if (size > 0 && textArray[0] != wxT(""))
{
for (UnsignedInt i=0; i<size; i++)
{
if (indentCommentOnly)
gen << indent << prefix << textArray[i];
else
gen << indent << textArray[i];
if (textArray[i].find(wxT("\n")) == cmdstr.npos &&
textArray[i].find(wxT("\r")) == cmdstr.npos)
{
gen << wxT("\n");
}
}
}
if (indentCommentOnly)
gen << prefix << cmd->GetTypeName() << wxT(";");
}
开发者ID:,项目名称:,代码行数:55,代码来源:
示例14: TextParser_splitRange
static PyObject* TextParser_splitRange(PyObject* self, PyObject* args)
{
PyObject* handle;
const char* value;
if(!PyArg_ParseTuple(args, "Os", &handle, &value))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
double from;
double to;
double step;
int ret = tp->splitRange(value, &from, &to, &step);
return Py_BuildValue("iddd", ret, from, to, step);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:17,代码来源:TextParser_python_api.cpp
示例15: TextParser_getAllLabels
static PyObject* TextParser_getAllLabels(PyObject* self, PyObject* args)
{
PyObject* handle;
if(!PyArg_ParseTuple(args, "O", &handle))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
std::vector<std::string> labels;
int ret = tp->getAllLabels(labels);
PyObject* py_labels = PyList_New(labels.size());
int i = 0;
for(std::vector<std::string>::iterator it = labels.begin(); it != labels.end(); ++it)
{
PyList_SetItem(py_labels, i++, Py_BuildValue("s", (*it).c_str()));
}
return Py_BuildValue("iO", ret, py_labels);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:19,代码来源:TextParser_python_api.cpp
示例16: TextParser_read
static PyObject* TextParser_read(PyObject* self, PyObject* args)
{
// 引数の解析
const char* filename;
PyObject* handle;
if(!PyArg_ParseTuple(args, "Os", &handle, &filename))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
int ret = tp->read(filename);
if(ret != 0)
{
std::cerr<<"MetaData read failed!! ("<<filename<<")"<<std::endl;
}
//戻り値を設定
return Py_BuildValue("i", ret);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:20,代码来源:TextParser_python_api.cpp
示例17: TextParser_expandRange
static PyObject* TextParser_expandRange(PyObject* self, PyObject* args)
{
PyObject* handle;
const char* value;
if(!PyArg_ParseTuple(args, "Os", &handle, &value))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
std::vector<double> expanded;
int ret = tp->expandRange(value, expanded);
PyObject* py_expanded = PyList_New(expanded.size());
int i = 0;
for(std::vector<double>::iterator it = expanded.begin(); it != expanded.end(); ++it)
{
PyList_SetItem(py_expanded, i++, Py_BuildValue("d", *it));
}
return Py_BuildValue("iO", ret, py_expanded);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:20,代码来源:TextParser_python_api.cpp
示例18: TextParser_splitList
static PyObject* TextParser_splitList(PyObject* self, PyObject* args)
{
PyObject* handle;
const char* value;
if(!PyArg_ParseTuple(args, "Os", &handle, &value))
{
return NULL;
}
TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle));
std::vector<double> list;
TextParserSortOrder order = TP_SORT_NONE;
int ret = tp->splitList(value, list, order);
PyObject* py_list = PyList_New(list.size());
int i = 0;
for(std::vector<double>::iterator it = list.begin(); it != list.end(); ++it)
{
PyList_SetItem(py_list, i++, Py_BuildValue("d", *it));
}
return Py_BuildValue("iO", ret, py_list);
}
开发者ID:s-tsutsumi,项目名称:TextParser,代码行数:20,代码来源:TextParser_python_api.cpp
示例19: ReadInputFile
// #################################################################
//
void COMB::ReadInit(string input_file)
{
// ------------------------------------
FILE* fp = NULL;
// TPインスタンス生成
TextParser tpCntl;
// 入力ファイルをセット
int ierror = tpCntl.read(input_file);
// 入力ファイルの読み込み--->パラメータのセット
ReadInputFile(&tpCntl);
// TextParserの破棄
tpCntl.remove();
return;
}
开发者ID:,项目名称:,代码行数:22,代码来源:
示例20: ReadInputFile
// #################################################################
//
void LAYOUT::ReadInit()
{
// ------------------------------------
FILE* fp = NULL;
// TPインスタンス生成
TextParser tpCntl;
//入力ファイルをセット
int ierror = tpCntl.read(fname);
//入力ファイルの読み込み--->パラメータのセット
ReadInputFile(&tpCntl);
//TextParserの破棄
tpCntl.remove();
return;
}
开发者ID:VisCore618,项目名称:FFVC,代码行数:23,代码来源:layout.C
注:本文中的TextParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论