Esempio n. 1
0
int fmll_svm_net_save(const fmll_svm_net * svm_net, const char * fname_prefix)
{
	int ret = 0;
	const unsigned num = svm_net->num;
	unsigned u;
	char node_name[4096];
	const fmll_svm ** svm = (const fmll_svm **) svm_net->svm;
	mxml_node_t * sub_node, * node, * content_node, * main_node = NULL;
		
	fmll_try;

		fmll_throw_if(xml_create(TYPE_SVM_NET, & main_node, & content_node));
		fmll_throw_if(xml_set_int(content_node, "num", num));
		fmll_throw_null(node = mxmlNewElement(content_node, "SVM"));

		for(u = 0; u < num; u++)
		{
			sprintf(node_name, "svm_%u", u);
			fmll_throw_null(sub_node = mxmlNewElement(node, node_name));
			fmll_throw_if(fmll_svm_save_main(svm[u], sub_node));
		}

		fmll_throw_if(xml_save(fname_prefix, main_node));

	fmll_catch;

		ret = -1;

	fmll_finally;

		xml_destroy(main_node);

	return ret;
}
Esempio n. 2
0
    /*
    ==============================
    ==============================
    */
    void IKAModule::End()
    {
        if(twLimb)
        {
            twLimb->Release();
            twLimb = 0;
        }

        xml_document<>* doc     = new xml_document<>;
        xml_node<>* nodeLimb    = xml_append_element(doc, doc, "Limb");
        xml_node<>* nodeArcball = xml_append_element(doc, doc, "ArcBall");

        if(limb)
        {
            SaveLimb(doc, nodeLimb);

            limb->Release();
            limb = 0;
        }

        if(arcBall)
        {
            SaveArcball(doc, nodeArcball);

            delete arcBall;
            arcBall = 0;
        }


        xml_save(doc, defaultFile);

        delete doc;
    }
Esempio n. 3
0
File: som.c Progetto: verzhak/fmll
int fmll_som_save(const fmll_som * som, const char * fname_prefix)
{
	int ret = 0;
	const unsigned num = som->num, map_dim = som->map_dim, dim = som->dim, * N = som->N;
	const double ** w = (const double **) som->w;
	char node_name[4096];
	unsigned u, v;
	mxml_node_t * sub_node, * node, * content_node, * main_node = NULL;
		
	fmll_try;

		fmll_throw_if(xml_create(TYPE_SOM, & main_node, & content_node));
		fmll_throw_if(xml_set_int(content_node, "map_dim", map_dim));
		fmll_throw_if(xml_set_int(content_node, "dim", dim));

		fmll_throw_null(node = mxmlNewElement(content_node, "N"));

		for(u = 0; u < map_dim; u++)
		{
			sprintf(node_name, "N_%u", u);
			fmll_throw_if(xml_set_int(node, node_name, N[u]));
		}

		fmll_throw_null(node = mxmlNewElement(content_node, "W"));

		for(u = 0; u < num; u++)
		{
			sprintf(node_name, "w_%u", u);
			fmll_throw_null(sub_node = mxmlNewElement(node, node_name));

			for(v = 0; v < dim; v++)
			{
				sprintf(node_name, "%u", v);
				fmll_throw_if(xml_set_double(sub_node, node_name, w[u][v]));
			}
		}


		fmll_throw_if(xml_save(fname_prefix, main_node));

	fmll_catch;

		ret = -1;

	fmll_finally;

		xml_destroy(main_node);

	return ret;
}
Esempio n. 4
0
File: pca.c Progetto: verzhak/fmll
int fmll_pca_save(const fmll_pca * pca, const char * fname_prefix)
{
	int ret = 0;
	const unsigned dim = pca->dim, num = pca->num;
	const double ** w = (const double **) pca->w;
	unsigned u, v;
	char node_name[4096];
	mxml_node_t * sub_node, * node, * main_node = NULL, * content_node;
		
	fmll_try;

		fmll_throw_if(xml_create(TYPE_PCA, & main_node, & content_node));
		fmll_throw_if(xml_set_int(content_node, "dim", dim));
		fmll_throw_if(xml_set_int(content_node, "num", num));

		fmll_throw_null(node = mxmlNewElement(content_node, "W"));

		for(u = 0; u < num; u++)
		{
			sprintf(node_name, "w_%u", u);
			fmll_throw_null(sub_node = mxmlNewElement(node, node_name));

			for(v = 0; v < dim; v++)
			{
				sprintf(node_name, "%u", v);
				fmll_throw_if(xml_set_double(sub_node, node_name, w[u][v]));
			}
		}

		fmll_throw_if(xml_save(fname_prefix, main_node));

	fmll_catch;

		ret = -1;

	fmll_finally;

		xml_destroy(main_node);

	return ret;
}
Esempio n. 5
0
/*
 * save a configuration, encrypting it if credentials found
 */
int cfg_save (XML *xml, char *path)
{
  int r;
  XML *x;

  cfg_clean (path);
  x = xml;
  if ((ConfigCert != NULL) || (ConfigPass != NULL))
  {
    unsigned char *p;

    p = xml_format (xml);
    x = xcrypt_encrypt (p, strlen (p) + 1, ConfigCert, NULL, 
      ConfigPass, AES256);
    free (p);
  }
  r = xml_save (x, path);
  if (x != xml)
    xml_free (x);
  return (r);
}