Esempio n. 1
0
    std::string ImgDescriptor::ToString() const
    {
        std::ostringstream ss;
        ss << Id << Sep() << Size << Sep() << Name;

        return ss.str();
    }
Esempio n. 2
0
    bool ImgDescriptor::setFromString( const std::string& str )
    {
        typedef std::string::size_type Idx;
        Idx  sep1 = str.find_first_of(Sep());
        Idx  sep2 = str.find_first_of(Sep(), sep1 + Sep().size());
        if (sep1 == std::string::npos) return false;
        if (sep2 == std::string::npos) return false;

        ImgDescriptor tmp;
        if ( !StringTo(tmp.Id, str.substr(0, sep1)) ) return false;
        if ( !StringTo(tmp.Size, str.substr(sep1 + Sep().size(), sep2 - sep1)) ) return false;
        tmp.Name = str.substr(sep2 + Sep().size());
        *this = tmp;
        return true;
    }
Esempio n. 3
0
bool
Extension::scanDir(const std::string& dirlist)
{
    GNASH_REPORT_FUNCTION;
    
    Tok t(dirlist, Sep(":"));
    for (Tok::iterator i = t.begin(), e = t.end(); i != e; ++i) {

        const std::string& dir = *i;

        log_debug(_("Scanning directory \"%s\" for plugins"), dir);
        DIR *libdir = opendir(dir.c_str());

        if (!libdir) {
            log_error(_("Can't open directory %s"), dir);
            return false;
        }   
        
        struct dirent *entry;

        while ((entry = readdir(libdir)) != NULL) {
            // We only want shared libraries that end with the suffix, otherwise
            // we get all the duplicates.
            std::string name(entry->d_name);

            // Hidden files.
            if (name.at(0) == '.') {
                continue;
            }            
                
            const std::string::size_type pos = name.find_last_of('.');
 
            if (pos == std::string::npos) continue;
 
            const std::string suffix = name.substr(pos);
            name.erase(pos);

            if (suffix == ".so") {
                log_debug(_("Gnash Plugin name: %s"), name);
                _modules.push_back(name);
            }
            else {
                continue;
            }
        }
        
        if (closedir(libdir) != 0) {
            return false;
        }
    }
    return true;
}
Esempio n. 4
0
// Second      Step   of    the       saito   algorithm    using    the
//[Meijster/Roerdnik/Hesselink] optimization
void phaseSaitoY(Var* vx, Var* vxy)
{
	int dx = GetX(vx);
	int dy = GetY(vx);
	int s[dy]; // Center of the upper envelope parabolas
	int t[dy]; // Separating index between 2 upper envelope parabolas
	int q;
	int w;
	int x, u;

	int* sdt_x  = V_DATA(vx);
	int* sdt_xy = V_DATA(vxy);

	for (x = 0; x < dx; x++) {
		q    = 0;
		s[0] = 0;
		t[0] = 0;

		// Forward Scan
		for (u = 1; u < dy; u++) {
			while ((q >= 0) &&
			       (F(t[q], s[q], prod(sdt_x[cpos(x, s[q], 0, vx)], sdt_x[cpos(x, s[q], 0, vx)])) >
			        F(t[q], u, prod(sdt_x[cpos(x, u, 0, vx)], sdt_x[cpos(x, u, 0, vx)]))))
				q--;

			if (q < 0) {
				q    = 0;
				s[0] = u;
			} else {
				w = 1 + Sep(s[q], u, prod(sdt_x[cpos(x, s[q], 0, vx)], sdt_x[cpos(x, s[q], 0, vx)]),
				            prod(sdt_x[cpos(x, u, 0, vx)], sdt_x[cpos(x, u, 0, vx)]));

				if (w < dy) {
					q++;
					s[q] = u;
					t[q] = w;
				}
			}
		}

		// Backward Scan
		for (u = dy - 1; u >= 0; --u) {
			sdt_xy[cpos(x, u, 0, vxy)] =
			    F(u, s[q], prod(sdt_x[cpos(x, s[q], 0, vx)], sdt_x[cpos(x, s[q], 0, vx)]));
			if (u == t[q]) q--;
		}
	}
}
Esempio n. 5
0
//---------------------------------------------------------------------------
bool TData::ImportPointSeries(const std::wstring &FileName, char Separator)
{
  const TColor Colors[] = {clRed, clGreen, clBlue, clYellow, clPurple, clAqua, clBlack, clGray, clSkyBlue	, clMoneyGreen, clDkGray};

  std::ifstream Stream(FileName.c_str());
  if(!Stream)
  {
		MessageBox(LoadRes(RES_NOT_GRAPH_FILE, FileName), LoadString(RES_FILE_ERROR), MB_ICONSTOP);
    return false;
  }

	std::string Line;
	while(Stream && Line.empty())
    std::getline(Stream, Line);
	if(Separator == 0)
	  Separator = GetSeparator(Line);

	std::vector<std::pair<std::wstring, std::vector<TPointSeriesPoint> > > Points;
	unsigned Row = 0;
	try
	{
    boost::escaped_list_separator<char> Sep("", std::string(1, Separator), "");
    unsigned Index = 0;
    do
    {
      ++Row;
      boost::tokenizer<boost::escaped_list_separator<char> > tok(Line, Sep);
      boost::tokenizer<boost::escaped_list_separator<char> >::iterator beg = tok.begin();
	    std::wstring xStr = ToWString(*beg);
      if(!xStr.empty() && xStr[0] == L'#')
      {
        Index = Points.size();
        Points.push_back(std::make_pair(xStr.substr(1), std::vector<TPointSeriesPoint>()));
        while(++beg != tok.end())
          Points.push_back(std::make_pair(ToWString(*beg), std::vector<TPointSeriesPoint>()));
      }
      else
      {
        unsigned Col = Index;
        while(++beg != tok.end())
		    {
          if(Col == Points.size())
     		    Points.push_back(std::make_pair(L"", std::vector<TPointSeriesPoint>()));
          std::wstring yStr = ToWString(*beg);
          if(Property.DecimalSeparator != '.')
          {
            std::replace(xStr.begin(), xStr.end(), Property.DecimalSeparator, L'.');
            std::replace(yStr.begin(), yStr.end(), Property.DecimalSeparator, L'.');
          }
          Points[Col].second.push_back(TPointSeriesPoint(xStr, yStr));
          Col++;
        }
			}
		}
	  while(std::getline(Stream, Line));
	}
	catch(Func32::EParseError &E)
	{
		MessageBox(LoadRes(526, FileName.c_str(), Row+1), LoadRes(RES_FILE_ERROR), MB_ICONSTOP);
		return false;
	}
	catch(std::out_of_range &E)
	{
		MessageBox(LoadRes(526, FileName.c_str(), Row+1), LoadRes(RES_FILE_ERROR), MB_ICONSTOP);
		return false;
  }
  catch(std::bad_alloc &E)
  {
    MessageBox(LoadRes(RES_OUT_OF_MEMORY), LoadRes(RES_FILE_ERROR), MB_ICONSTOP);
    return false;
  }

	unsigned ColorIndex = 0;
  unsigned Style = Property.DefaultPoint.Style;
  unsigned LineStyle = Property.DefaultPointLine.Style;

	UndoList.BeginMultiUndo();
	for(unsigned I = 0; I < Points.size(); I++)
	{
		boost::shared_ptr<TPointSeries> Series(new TPointSeries(
			clBlack,            //FrameColor
			Colors[ColorIndex], //FillColor
			Colors[ColorIndex], //LineColor
			Property.DefaultPoint.Size, //Size
			Property.DefaultPointLine.Size, //LineSize
			Style, //Style
			static_cast<TPenStyle>(LineStyle), //LineStyle
			iaLinear, //Onterpolation
			false, //ShowLabels
			Property.DefaultPointLabelFont, //Font
			lpBelow, //LabelPosition
			ptCartesian, //PointType
			ebtNone,  //xErrorBarType
			0, //xErrorValues
			ebtNone, //yErrorBarType
			0 //yErrorValue
		));
		Series->Swap(Points[I].second);
		Series->SetLegendText(Points[I].first.empty() ? CreatePointSeriesDescription() : Points[I].first);
		Insert(Series);
		UndoList.Push(TUndoAdd(Series));
		Series->Update();
		ColorIndex = ++ColorIndex % (sizeof(Colors)/sizeof(TColor));
		Style = (Style+1) % 7;
		LineStyle = (LineStyle+1) % 5;
  }

  UndoList.EndMultiUndo();
  Modified = true;
  return true;
}