Beispiel #1
0
    status_t ctml_getfloatarray_(const integer* i, const integer* n,
                                 doublereal* data, const integer* iconvert)
    {
        try {
            XML_Node& node = *_xml(i);
            Cantera::vector_fp v;
            bool conv = false;
            if (*iconvert > 0) {
                conv = true;
            }
            getFloatArray(node, v, conv);
            int nv = v.size();

            // array not big enough
            if (*n < nv) {
                throw CanteraError("ctml_getfloatarray",
                                   "array must be dimensioned at least "+Cantera::int2str(nv));
            }

            for (int i = 0; i < nv; i++) {
                data[i] = v[i];
            }
        } catch (...) {
            return handleAllExceptions(-1, ERR);
        }
        return 0;
    }
Beispiel #2
0
 status_t DLL_EXPORT fxml_findid_(const integer* i, const char* id, ftnlen idlen) {
     try {
         XML_Node& node = *_xml(i);
         XML_Node* c = node.findID(f2string(id, idlen));
         if (c) {
             return Cabinet<XML_Node>::cabinet()->add(c);
         }
         else 
             throw CanteraError("fxml_find_id","id not found: "+f2string(id, idlen));
     }
     catch (CanteraError) { handleError(); }
     return 0;
 }
Beispiel #3
0
 status_t DLL_EXPORT fxml_findbyname_(const integer* i, const char* nm, ftnlen nmlen) {
     try {
         XML_Node& node = *_xml(i);
         XML_Node* c = node.findByName(f2string(nm, nmlen));
         if (c) {
             return Cabinet<XML_Node>::cabinet()->add(c);
         }
         else 
             throw CanteraError("fxml_findByName","name "+f2string(nm, nmlen)
                 +" not found");
     }
     catch (CanteraError) { handleError(); }
     return 0;
 }
Beispiel #4
0
 status_t fxml_findid_(const integer* i, const char* id, ftnlen idlen)
 {
     try {
         XML_Node& node = *_xml(i);
         XML_Node* c = node.findID(f2string(id, idlen));
         if (c) {
             return XmlCabinet::add(c);
         } else {
             throw CanteraError("fxml_find_id","id not found: "+f2string(id, idlen));
         }
     } catch (...) {
         return handleAllExceptions(-1, ERR);
     }
     return 0;
 }
Beispiel #5
0
 status_t fxml_findbyname_(const integer* i, const char* nm, ftnlen nmlen)
 {
     try {
         XML_Node& node = *_xml(i);
         XML_Node* c = node.findByName(f2string(nm, nmlen));
         if (c) {
             return XmlCabinet::add(c);
         } else {
             throw CanteraError("fxml_findByName","name "+f2string(nm, nmlen)
                                +" not found");
         }
     } catch (...) {
         return handleAllExceptions(-1, ERR);
     }
     return 0;
 }
Beispiel #6
0
 status_t DLL_EXPORT fxml_attrib_(const integer* i, const char* key, 
     char* value, ftnlen keylen, ftnlen valuelen) {
     try {
         std::string ky = f2string(key, keylen);
         XML_Node& node = *_xml(i);
         if (node.hasAttrib(ky)) {
             std::string v = node[ky];
             strncpy(value, v.c_str(), valuelen);
         }
         else 
             throw CanteraError("fxml_attrib","node "
                 " has no attribute '"+ky+"'");
     }
     catch (CanteraError) { handleError(); }
     return 0;
 }
Beispiel #7
0
 status_t DLL_EXPORT fxml_write_(const integer* i, const char* file, ftnlen filelen) {
     try {
         std::string ff(file, filelen);
         ofstream f(ff.c_str());
         if (f) {
             XML_Node& node = *_xml(i);
             node.write(f);
         }
         else {
             throw CanteraError("fxml_write",
                 "file "+f2string(file, filelen)+" not found.");
         }
         return 0;
     }
     catch (CanteraError) { handleError(); }
     return 0;
 }
Beispiel #8
0
 status_t fxml_attrib_(const integer* i, const char* key, char* value,
                       ftnlen keylen, ftnlen valuelen)
 {
     try {
         std::string ky = f2string(key, keylen);
         XML_Node& node = *_xml(i);
         if (node.hasAttrib(ky)) {
             std::string v = node[ky];
             strncpy(value, v.c_str(), valuelen);
         } else {
             throw CanteraError("fxml_attrib","node "
                                " has no attribute '"+ky+"'");
         }
     } catch (...) {
         return handleAllExceptions(-1, ERR);
     }
     return 0;
 }
Beispiel #9
0
 status_t fxml_write_(const integer* i, const char* file, ftnlen filelen)
 {
     try {
         std::string ff(file, filelen);
         ofstream f(ff.c_str());
         if (f) {
             XML_Node& node = *_xml(i);
             node.write(f);
         } else {
             throw CanteraError("fxml_write",
                                "file "+f2string(file, filelen)+" not found.");
         }
         return 0;
     } catch (...) {
         return handleAllExceptions(-1, ERR);
     }
     return 0;
 }