Exemplo n.º 1
0
void IOVector3D::Write(MdfStream& fd, Vector3D* vector, Version* version, MgTab& tab)
{
    _ASSERT(NULL != vector);

    fd << tab.tab() << startStr(sViewDirection) << std::endl;
    tab.inctab();

    // Property: X
    fd << tab.tab() << startStr(sX);
    fd << DoubleToStr(vector->GetX());
    fd << endStr(sX) << std::endl;

    // Property: Y
    fd << tab.tab() << startStr(sY);
    fd << DoubleToStr(vector->GetY());
    fd << endStr(sY) << std::endl;

    // Property: Z
    fd << tab.tab() << startStr(sZ);
    fd << DoubleToStr(vector->GetZ());
    fd << endStr(sZ) << std::endl;

    tab.dectab();
    fd << tab.tab() << endStr(sViewDirection) << std::endl;
}
Exemplo n.º 2
0
void IOPoint3D::Write(MdfStream& fd, Point3D* point, Version* version, const std::string& name, MgTab& tab)
{
    _ASSERT(NULL != point);

    fd << tab.tab() << startStr(name) << std::endl;
    tab.inctab();

    // Property: X
    fd << tab.tab() << startStr(sX);
    fd << DoubleToStr(point->GetX());
    fd << endStr(sX) << std::endl;

    // Property: Y
    fd << tab.tab() << startStr(sY);
    fd << DoubleToStr(point->GetY());
    fd << endStr(sY) << std::endl;

    // Property: Z
    fd << tab.tab() << startStr(sZ);
    fd << DoubleToStr(point->GetZ());
    fd << endStr(sZ) << std::endl;

    tab.dectab();
    fd << tab.tab() << endStr(name) << std::endl;
}
Exemplo n.º 3
0
bool RequestParser::ParseRange(const string& s,
                               int64_t& start,
                               int64_t& end)
{
  // Range: bytes=start,end
  size_t sp = s.find(" ");
  size_t eq = s.find("=");
  if (sp == string::npos || eq == string::npos)
    return false;
  string bytes(s, sp + 1, eq - sp - 1);
  if (bytes != "bytes") {
    // The space is not followed by "bytes=", this is an invalid range param.
    return false;
  }

  string range(s, eq + 1);
  size_t dash = range.find("-");
  if (dash == string::npos)
    return false;
  string startStr(range, 0, dash);
  string endStr(range, dash + 1);

  start = atoll(startStr.c_str());
  if (endStr != "") {
    end = atoll(endStr.c_str());
  } else {
    end = -1;
  }

  return true;
}
Exemplo n.º 4
0
int main(int argc, char ** argv)
{
    time_t start,end;
	struct tm startInfo;
	struct tm endInfo;
	double duration;
	start = time(NULL);
	localtime_s(&startInfo, &start);
	char buffer[32];
	char buffer_end[32];
	asctime_s(buffer, 32, &startInfo);
	string startStr(buffer);
    float alpha1 = 0.007;    //according suggestion of xlvector
    float alpha2 = 0.007;    //according suggestion of xlvector
    float beta1  = 0.01;     //according suggestion of xlvector
    float beta2  = 0.01;     //according suggestion of xlvector  
    //for(int i=0; i < 10; i++)
    {
        //    beta = i*0.001 + 0.002;
        //    cout << beta << endl;
        svd::model(K_NUM,alpha1,alpha2,beta1,beta2,60,0.9);
    }
    end = time(NULL);
    duration = end-start;
	localtime_s(&endInfo, &end);
	asctime_s(buffer_end, 32, &endInfo);
	string endStr(buffer_end);
	cout << "start at" << startStr << ". And end at " << endStr << endl;
    cout << "duration:"<<duration <<" s!" <<endl;
    return 0;
}
Exemplo n.º 5
0
void IOMapViewportDefinition::Write(MdfStream& fd, MapViewportDefinition* mapViewportDef, Version* version, MgTab& tab)
{
    _ASSERT(NULL != mapViewportDef);

    // Set the expected version
    MdfString strVersion = L"2.0.0";

    fd << tab.tab() << "<PrintLayoutElementDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"PrintLayoutDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
    tab.inctab();

    fd << tab.tab() << startStr(sMapViewportDefinition) << std::endl;
    tab.inctab();

    IOPrintLayoutElementDefinition::Write(fd, mapViewportDef, version, tab);

    // Property: MapName
    fd << tab.tab() << startStr(sMapName);
    fd << EncodeString(mapViewportDef->GetMapName());
    fd << endStr(sMapName) << std::endl;

    // Property: HiddenLayerNames
    IOStringObjectCollection::Write(fd, mapViewportDef->GetHiddenLayerNames(), version, sHiddenLayerNames, sName, tab);

    // Property: Locked
    fd << tab.tab() << startStr(sLocked);
    fd << BoolToStr(mapViewportDef->GetIsLocked());
    fd << endStr(sLocked) << std::endl;

    // Property: On
    fd << tab.tab() << startStr(sOn);
    fd << BoolToStr(mapViewportDef->GetIsOn());
    fd << endStr(sOn) << std::endl;

    // Property: MapView
    IOMapView::Write(fd, mapViewportDef->GetMapView(), version, tab);

    tab.dectab();
    fd << tab.tab() << endStr(sMapViewportDefinition) << std::endl;

    tab.dectab();
    fd << tab.tab() << "</PrintLayoutElementDefinition>" << std::endl; // NOXLATE
}
Exemplo n.º 6
0
void IOPropertyMappingCollection::Write(MdfStream& fd, PropertyMappingCollection* propMappings, Version* version, const std::string& name, MgTab& tab)
{
    _ASSERT(NULL != propMappings);

    fd << tab.tab() << startStr(name) << std::endl;
    tab.inctab();

    for (int i = 0; i < propMappings->GetCount(); ++i)
    {
       fd << tab.tab() << startStr(sPropertyMapping) << std::endl;
       tab.inctab();

        PropertyMapping* propMapping = dynamic_cast<PropertyMapping*>(propMappings->GetAt(i));
        _ASSERT(NULL != propMapping);

        // Property: TargetProperty
        fd << tab.tab() << startStr(sTargetProperty);
        fd << EncodeString(propMapping->GetTargetProperty());
        fd << endStr(sTargetProperty) << std::endl;

        // Property: SourceProperty
        fd << tab.tab() << startStr(sSourceProperty);
        fd << EncodeString(propMapping->GetSourceProperty());
        fd << endStr(sSourceProperty) << std::endl;

        // Property: SourceUnits
        fd << tab.tab() << startStr(sSourceUnits);
        fd << EncodeString(propMapping->GetSourceUnits());
        fd << endStr(sSourceUnits) << std::endl;

        // Write any unknown XML / extended data
        IOUnknown::Write(fd, propMapping->GetUnknownXml(), version, tab);

        tab.dectab();
        fd << tab.tab() << endStr(sPropertyMapping) << std::endl;
    }

    tab.dectab();
    fd << tab.tab() << endStr(name) << std::endl;
}