// ################################################################# // 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; }
static PyObject* TextParser_getNodes(PyObject* self, PyObject* args) { PyObject* handle; int oswitch=0; if(!PyArg_ParseTuple(args, "O|i", &handle, &oswitch)) { return NULL; } TextParser* tp = static_cast<TextParser*>(PyCObject_AsVoidPtr(handle)); std::vector<std::string> labels; int ret = tp->getNodes(labels, oswitch); 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); }