示例#1
0
ProjectSettings *ProjectSettings::Clone() const
{
    wxXmlNode *node = ToXml();
    ProjectSettings *cloned = new ProjectSettings(node);
    delete node;
    return cloned;
}
示例#2
0
BuildConfig* BuildConfig::Clone() const
{
    wxXmlNode* node = ToXml();
    BuildConfig* cloned = new BuildConfig(node);
    delete node;
    return cloned;
}
示例#3
0
void UserSettings::Save() {
  TiXmlDocument doc;
  doc.LinkEndChild(new TiXmlDeclaration("1.0", "", ""));
  TiXmlElement* xmlRoot = ToXml();
  xmlRoot->SetAttribute("version", "1.0");
  doc.LinkEndChild(xmlRoot);

  wxString filePath = FilePaths::GetSettingsFile();

  FilePaths::CreateSettingsDirectory();
  doc.SaveFile(filePath.mb_str());
}
void ribi::cmap::Edge::Test() noexcept
{
  {
    static bool is_tested = false;
    if (is_tested) return;
    is_tested = true;
  }
  //Test member variables
  TRACE("Started ribi::cmap::Edge::Test");
  {
    const auto nodes = Node::GetTests();
    assert(nodes.size() >= 2);
    const auto node_from = nodes[0];
    const auto node_to   = nodes[1];
    for (const boost::shared_ptr<const cmap::Edge>& edge: EdgeFactory::GetTests(node_from,node_to))
    {
      //Test copy constructor
      assert(edge);
      const boost::shared_ptr<const cmap::Edge> c = cmap::EdgeFactory::DeepCopy(edge,node_from,node_to);
      assert(c);
      assert(*edge == *c);
      assert(*c == *edge);
      assert(*c->GetFrom() == *node_from);
      assert(*c->GetFrom() == *nodes[0]);
      assert(*c->GetTo() == *node_to);
      assert(*c->GetTo() == *nodes[1]);
      const std::string s = ToXml(c,AddConst(nodes));
      const boost::shared_ptr<ribi::cmap::Edge> d = cmap::EdgeFactory::FromXml(s,nodes);
      assert(d);
      if (*c != *d)
      {
        TRACE("ERROR");
        TRACE(ToXml(c,AddConst(nodes)));
        TRACE(ToXml(d,AddConst(nodes)));
      }
      assert(*c == *d);
    }
  }
  TRACE("Edge::Test finished successfully");
}
示例#5
0
static
void ToXml(const DataSetElement& node,
           const NamespaceRegistry& registry,
           map<XsdType, string>& xsdPrefixesUsed,
           pugi::xml_node& parentXml)
{
    // create child of parent, w/ label & text
    const string& label = OutputName(node, registry);
    if (label.empty())
        return; // error?
    pugi::xml_node xmlNode = parentXml.append_child(label.c_str());

    if (!node.Text().empty())
        xmlNode.text().set(node.Text().c_str());

    // store XSD type for later
    const string prefix = Prefix(label);
    if (!prefix.empty())
        xsdPrefixesUsed[node.Xsd()] = prefix;

    // add attributes
    auto attrIter = node.Attributes().cbegin();
    auto attrEnd  = node.Attributes().cend();
    for ( ; attrIter != attrEnd; ++attrIter) {
        const string& name = attrIter->first;
        if (name.empty())
            continue;
        pugi::xml_attribute attr = xmlNode.append_attribute(name.c_str());
        attr.set_value(attrIter->second.c_str());
    }

    // additional stuff later? (e.g. comments)

    // iterate children, recursively building up subtree
    auto childIter = node.Children().cbegin();
    auto childEnd  = node.Children().cend();
    for ( ; childIter != childEnd; ++childIter) {
        const DataSetElement& child = (*childIter);
        ToXml(child, registry, xsdPrefixesUsed, xmlNode);
    }
}
示例#6
0
int main( int argc, char *argv[] ){

    pid_t pid, sid;

    pid = fork();
    if (pid < 0) {
            exit(EXIT_FAILURE);
    }

    if (pid > 0) {
            exit(EXIT_SUCCESS);
    }

    umask(0);

    openlog("EPGREAD_LOG:", LOG_PID|LOG_CONS, LOG_USER);

    sid = setsid();
    if (sid < 0) {
            syslog(LOG_INFO, "SID fail");
            exit(EXIT_FAILURE);
    }


    if ((chdir("/")) < 0) {
            /* Log the failure */
             syslog(LOG_INFO, "chdir fail");
            exit(EXIT_FAILURE);
    }

    close(STDIN_FILENO);
    close(STDOUT_FILENO);
    close(STDERR_FILENO);


    int adapter = 0;
    int frontend = 0;
    int demux = 0;
    int opt;
    char channelsfile[128] = "/tmp/channels.conf";
    int lnb = 0;

    char xmlPath[128] = "/tmp/XML/";


    while ((opt = getopt(argc, argv, "a:f:d:c:l:t:")) != -1) {
        switch (opt) {
        case 'a':
            adapter = strtoul(optarg, NULL, 0);
            break;
        case 'f':
            frontend = strtoul(optarg, NULL, 0);
            break;
        case 'd':
            demux = strtoul(optarg, NULL, 0);
            break;
        case 'c':
            strncpy(channelsfile, optarg, sizeof(channelsfile));
            break;
        case 'l':
            lnb = strtoul(optarg, NULL, 0);
            break;
        case 't':
            strncpy(xmlPath, optarg, sizeof(xmlPath));
            break;
        }
    }
    if(lnb < 5){
        lnb_type = lnbs[lnb];
    }
    else {
        syslog(LOG_INFO, "Bad lnb number: %d", lnb );
        return -1;
    }


    snprintf(dedev, sizeof(dedev), DEMUXDEVICE, adapter, demux);
    snprintf(frdev, sizeof(frdev), FRONTENDDEVICE, adapter, frontend);






    FILE *fchannels = fopen(channelsfile, "r");
    if (fchannels == NULL) {

        syslog(LOG_INFO, "Unable to open %s\n", channelsfile);
        exit(1);
    }

    while (1) {

        dvbcfg_zapchannel_parse(fchannels, channels_cb, NULL);

        events.sort(SortCompare);

        ToXml(xmlPath, channels, events);

        sleep(10); /* wait 10 seconds */

        fseek(fchannels, 0, SEEK_SET);
    }


    fclose(fchannels);
    exit(EXIT_SUCCESS);

}
void pvdb::Cluster::Test()
{
  {
    static bool is_tested = false;
    if (is_tested) return;
    is_tested = true;
  }
  TRACE("Cluster::Test started");
  //Test operator== and operator!=
  {
    const std::vector<boost::shared_ptr<pvdb::Cluster> > tmp_tests_1 = pvdb::ClusterFactory::GetTests();
    assert(std::count_if(tmp_tests_1.begin(),tmp_tests_1.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return !p; } ) == 0); //FIX 2013-01-02
    //assert(std::all_of(tmp_tests_1.begin(),tmp_tests_1.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return p; } )); //BUG IN CROSSCOMPILER 2013-01-02
    const int sz = static_cast<int>(tmp_tests_1.size());
    for (int i=0; i!=sz; ++i)
    {
      const std::vector<boost::shared_ptr<pvdb::Cluster> > tmp_tests_a = pvdb::ClusterFactory::GetTests(); //For crosscompiler
      assert(std::count_if(tmp_tests_a.begin(),tmp_tests_a.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return !p; } ) == 0);
      //assert(std::all_of(tmp_tests_a.begin(),tmp_tests_a.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return p; } ));
      const boost::shared_ptr<const pvdb::Cluster> a = tmp_tests_a.at(i);
      assert(a);
      const std::vector<boost::shared_ptr<pvdb::Cluster> > tmp_tests_b = pvdb::ClusterFactory::GetTests(); //For crosscompiler
      assert(std::count_if(tmp_tests_b.begin(),tmp_tests_b.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return !p; } ) == 0);
      //assert(std::all_of(tmp_tests_b.begin(),tmp_tests_b.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return p; } ));
      const boost::shared_ptr<pvdb::Cluster> b = tmp_tests_b.at(i);
      assert(a); assert(b);
      assert(a==a);
      assert(a==b);
      assert(b==a);
      assert(b==b);
      for (int j=0; j!=sz; ++j)
      {
        const std::vector<boost::shared_ptr<pvdb::Cluster> > tmp_tests_c = pvdb::ClusterFactory::GetTests(); //For crosscompiler
        assert(std::count_if(tmp_tests_c.begin(),tmp_tests_c.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return !p; } ) == 0);
        //assert(std::all_of(tmp_tests_c.begin(),tmp_tests_c.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return p; } ));
        const std::vector<boost::shared_ptr<pvdb::Cluster> > tmp_tests_d = pvdb::ClusterFactory::GetTests(); //For crosscompiler
        assert(std::count_if(tmp_tests_d.begin(),tmp_tests_d.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return !p; } ) == 0);
        //assert(std::all_of(tmp_tests_d.begin(),tmp_tests_d.end(),[](const boost::shared_ptr<pvdb::Cluster>& p) { return p; } ));

        const boost::shared_ptr<const pvdb::Cluster> c = tmp_tests_c.at(j);
        assert(c);
        const boost::shared_ptr<      pvdb::Cluster> d = tmp_tests_d.at(j);
        assert(c); assert(d);
        assert(c==c); assert(c==d); assert(d==c); assert(d==d);
        if (i==j)
        {
          assert(a==c); assert(a==d);
          assert(b==c); assert(b==d);
          assert(c==a); assert(c==b);
          assert(d==a); assert(d==b);
        }
        else
        {
          assert(a!=c); assert(a!=d);
          assert(b!=c); assert(b!=d);
          assert(c!=a); assert(c!=b);
          assert(d!=a); assert(d!=b);
        }
      }
    }
  }
  //Test all Clusters with each combination of Concepts
  {
    const std::vector<std::vector<boost::shared_ptr<pvdb::Concept> > > v
      = GetCombinations(pvdb::ConceptFactory::GetTests());
    std::for_each(v.begin(),v.end(),
      [](const std::vector<boost::shared_ptr<pvdb::Concept> >& concepts)
      {
        const boost::shared_ptr<pvdb::Cluster> c(new pvdb::Cluster(concepts));
        assert(c);
        const std::string s = ToXml(c);
        const boost::shared_ptr<pvdb::Cluster> d = FromXml(s);
        assert(d);
        assert(c == d);
      }
    );
  }
  TRACE("Cluster::Test finished successfully");
}
示例#8
0
void pvdb::Node::Test()
{
  {
    static bool is_tested = false;
    if (is_tested) return;
    is_tested = true;
  }
  TRACE("Started pvdb::Node::Test");
  {
    const std::vector<boost::shared_ptr<pvdb::Node> > v = pvdb::Node::GetTests();
    std::for_each(v.begin(),v.end(),
      [](const boost::shared_ptr<pvdb::Node>& node)
      {
        //Test copy constructor
        const boost::shared_ptr<const pvdb::Node> c = NodeFactory::DeepCopy(node);
        assert(node == c);
        const std::string s = ToXml(c);
        const boost::shared_ptr<pvdb::Node> d = FromXml(s);
        assert(c == d);
      }
    );
  }
  //Test HasSameContent
  {
    {
      const boost::shared_ptr<pvdb::Concept> c(pvdb::ConceptFactory::Create("1"));
      const boost::shared_ptr<pvdb::Concept> d(pvdb::ConceptFactory::Create("1"));
      assert(c == d);
      const boost::shared_ptr<pvdb::Node> a(new Node(c));
      const boost::shared_ptr<pvdb::Node> b(new Node(d));
      assert(HasSameContent(a,b));
      assert(a == b);
    }
    const int sz = static_cast<int>(ConceptFactory::GetTests().size());
    for (int i=0; i!=sz; ++i)
    {
      const boost::shared_ptr<pvdb::Concept> c = ConceptFactory::Create("1", { {"2", pvdb::Competency::uninitialized} } );
      const boost::shared_ptr<pvdb::Concept> d = ConceptFactory::Create("1", { {"2", pvdb::Competency::uninitialized} } );
      assert(&c != &d);
      assert(c == d);
      const boost::shared_ptr<pvdb::Node> a(new Node(c));
      const boost::shared_ptr<pvdb::Node> b(new Node(d));
      assert(HasSameContent(a,b));
    }

    {
      //Cannot shuffle Concept its examples. No need to as well: the order is important
      const boost::shared_ptr<pvdb::Concept> c = ConceptFactory::Create("1", { {"2", pvdb::Competency::uninitialized},{"3", pvdb::Competency::uninitialized} } );
      const boost::shared_ptr<pvdb::Concept> d = ConceptFactory::Create("1", { {"2", pvdb::Competency::uninitialized},{"3", pvdb::Competency::uninitialized} } );
      assert(c == d);
      const boost::shared_ptr<pvdb::Node> a(new Node(c));
      const boost::shared_ptr<pvdb::Node> b(new Node(d));
      assert(HasSameContent(a,b));
      assert(a == b);
    }
    {
      //Cannot shuffle Concept its examples. No need to as well: the order is important
      const boost::shared_ptr<pvdb::Concept> c = ConceptFactory::Create("1", { {"2", pvdb::Competency::uninitialized},{"3", pvdb::Competency::uninitialized} } );
      const boost::shared_ptr<pvdb::Concept> d = ConceptFactory::Create("1", { {"3", pvdb::Competency::uninitialized},{"2", pvdb::Competency::uninitialized} } );
      assert(c != d);
      const boost::shared_ptr<pvdb::Node> a(new Node(c));
      const boost::shared_ptr<pvdb::Node> b(new Node(d));
      assert(!HasSameContent(a,b) && "Order in examples is important and cannot be shuffled");
      assert(a != b);
    }
    {
      //Cannot shuffle Concept its examples. No need to as well: the order is important
      const boost::shared_ptr<pvdb::Concept> c = ConceptFactory::Create("1", { {"2", pvdb::Competency::uninitialized},{"3", pvdb::Competency::uninitialized} } );
      const boost::shared_ptr<pvdb::Concept> d = ConceptFactory::Create("1", { {"2", pvdb::Competency::uninitialized} } );
      assert(c != d);
      const boost::shared_ptr<pvdb::Node> a(new Node(c));
      const boost::shared_ptr<pvdb::Node> b(new Node(d));
      assert(!HasSameContent(a,b));
      assert(a != b);
    }
  }
  //Test ConceptFactory reproductions
  {
    const int sz = static_cast<int>(ConceptFactory::GetTests().size());
    for (int i=0; i!=sz; ++i)
    {
      const boost::shared_ptr<pvdb::Concept> c = ConceptFactory::GetTests()[i];
      const boost::shared_ptr<pvdb::Concept> d = ConceptFactory::GetTests()[i];
      assert(&c != &d);
      assert(c == d);
      const boost::shared_ptr<pvdb::Node> a(new Node(c));
      const boost::shared_ptr<pvdb::Node> b(new Node(d));
      assert(HasSameContent(a,b));
      assert(a==b);
    }
  }
  //Test ConceptFactory reproductions
  {
    const int sz = static_cast<int>(ConceptFactory::GetTests().size());
    for (int i=0; i!=sz; ++i)
    {
      for (int j=0; j!=sz; ++j)
      {
        const boost::shared_ptr<pvdb::Concept> c = ConceptFactory::GetTests()[i];
        const boost::shared_ptr<pvdb::Concept> d = ConceptFactory::GetTests()[j];
        if (i!=j)
        {
          assert(&c != &d);
          assert(c != d);
          const boost::shared_ptr<pvdb::Node> a(new Node(c));
          const boost::shared_ptr<pvdb::Node> b(new Node(d));
          assert(!HasSameContent(a,b));
          assert(a != b);
        }
        else
        {
          assert(&c != &d);
          assert(c == d);
          const boost::shared_ptr<pvdb::Node> a(new Node(c));
          const boost::shared_ptr<pvdb::Node> b(new Node(d));
          assert(HasSameContent(a,b));
          assert(a == b);
        }
      }
    }
  }

  TRACE("Node::Test finished successfully");
}
void ribi::pvdb::Cluster::Test() noexcept
{
    {
        static bool is_tested = false;
        if (is_tested) return;
        is_tested = true;
    }
#ifdef MXE_SUPPORTS_THREADS
    std::thread t(
        []
    {
#endif

        TRACE("Cluster::Test started");
        //Test operator== and operator!=
        {
            const std::vector<boost::shared_ptr<ribi::pvdb::Cluster> > tmp_tests_1 = ribi::pvdb::ClusterFactory::GetTests();
            const int sz = static_cast<int>(tmp_tests_1.size());
            for (int i=0; i!=sz; ++i)
            {
                const std::vector<boost::shared_ptr<ribi::pvdb::Cluster> > tmp_tests_a = ribi::pvdb::ClusterFactory::GetTests(); //For crosscompiler
                const boost::shared_ptr<const ribi::pvdb::Cluster> a = tmp_tests_a.at(i);
                if (!a) continue;
                assert(a);
                const std::vector<boost::shared_ptr<ribi::pvdb::Cluster> > tmp_tests_b = ribi::pvdb::ClusterFactory::GetTests(); //For crosscompiler
                const boost::shared_ptr<ribi::pvdb::Cluster> b = tmp_tests_b.at(i);
                if (!b) continue;
                assert(a);
                assert(b);
                assert(operator==(*a,*a));
                assert(operator==(*a,*b));
                assert(operator==(*b,*a));
                assert(operator==(*b,*b));
                for (int j=0; j!=sz; ++j)
                {
                    const std::vector<boost::shared_ptr<ribi::pvdb::Cluster> > tmp_tests_c = ribi::pvdb::ClusterFactory::GetTests(); //For crosscompiler
                    const std::vector<boost::shared_ptr<ribi::pvdb::Cluster> > tmp_tests_d = ribi::pvdb::ClusterFactory::GetTests(); //For crosscompiler
                    const boost::shared_ptr<const ribi::pvdb::Cluster> c = tmp_tests_c.at(j);
                    if (!c) continue;
                    assert(c);
                    const boost::shared_ptr<ribi::pvdb::Cluster> d = tmp_tests_d.at(j);
                    if (!d) continue;
                    assert(c);
                    assert(d);
                    assert(operator==(*c,*c));
                    assert(operator==(*c,*d));
                    assert(operator==(*d,*c));
                    assert(operator==(*d,*d));
                    if (i==j)
                    {
                        assert(operator==(*a,*c));
                        assert(operator==(*a,*d));
                        assert(operator==(*b,*c));
                        assert(operator==(*b,*d));
                        assert(operator==(*c,*a));
                        assert(operator==(*c,*b));
                        assert(operator==(*d,*a));
                        assert(operator==(*d,*b));
                    }
                    else
                    {
                        assert(!operator==(*a,*c));
                        assert(!operator==(*a,*d));
                        assert(!operator==(*b,*c));
                        assert(!operator==(*b,*d));
                        assert(!operator==(*c,*a));
                        assert(!operator==(*c,*b));
                        assert(!operator==(*d,*a));
                        assert(!operator==(*d,*b));
                    }
                }
            }
        }
        //Test all Clusters with each combination of Concepts
        {
            const std::vector<std::vector<boost::shared_ptr<ribi::cmap::Concept> > > v
            = GetCombinations(cmap::ConceptFactory().GetTests());
            std::for_each(v.begin(),v.end(),
            [](const std::vector<boost::shared_ptr<ribi::cmap::Concept> >& concepts)
            {
                const boost::shared_ptr<ribi::pvdb::Cluster> c(new ribi::pvdb::Cluster(concepts));
                assert(c);
                const std::string s = ToXml(c);
                const boost::shared_ptr<ribi::pvdb::Cluster> d = FromXml(s);
                assert(d);
                assert(c != d);
                assert(operator==(*c,*d));
            }
                         );
        }
        TRACE("Cluster::Test finished successfully");

#ifdef MXE_SUPPORTS_THREADS
    }
    );
    t.detach();
#endif
}
示例#10
0
std::ostream& ribi::cmap::operator<<(std::ostream& os, const ConceptMap& conceptmap) noexcept
{
  os << graphviz_encode(ToXml(conceptmap));
  return os;
}