wxString* PROJECT_TEMPLATE::GetTitle(void)
{
    wxFileInputStream input( GetHtmlFile().GetFullPath() );
    wxString separator( wxT( "\x9" ) );
    wxTextInputStream text( input, separator, wxConvUTF8 );

    /* Open HTML file and get the text between the title tags */
    if( title == wxEmptyString )
    {
        int start = 0;
        int finish = 0;
        bool done = false;

        while( input.IsOk() && !input.Eof() && !done )
        {
            wxString line = text.ReadLine();

            start = line.Find( wxT( "<title>" ) );
            if( start == wxNOT_FOUND )
                start = line.Find( wxT( "<TITLE>" ) );

            finish = line.Find( wxT( "</title>" ) );
            if( finish == wxNOT_FOUND )
                finish = line.Find( wxT( "</TITLE>" ) );

            // find the opening tag
            if( start != wxNOT_FOUND )
            {
                if( finish != wxNOT_FOUND )
                {
                    title = line.SubString( start + 7, finish );
                }
                else
                {
                    title = line.SubString( start + 7, line.Len() - 1 );
                    done = true;
                }
            }
            else
            {
                if( finish != wxNOT_FOUND )
                {
                    title += line.SubString( 0, finish );
                    done = true;
                }
                else
                {
                    title += line;
                }
            }

            // Remove line endings
            title.Replace( wxT( "\r" ), wxT( "" ) );
            title.Replace( wxT( "\n" ), wxT( "" ) );
        }
    }

    return &title;
}
void PathListEditor::setPathList(const QString &pathString)
{
    if (pathString.isEmpty()) {
        clear();
    } else {
        setPathList(pathString.split(separator(), QString::SkipEmptyParts));
    }
}
Beispiel #3
0
 /*! \fn
   * Split a line (series of characters) with the given delimiter
   * @param line Input string in order to be split by the given delimiter
   * @param delim Series of delimiters (each delimiter character is followed by the next one in a single string variable) in order to split the given string
   * @return Vector of elements of the given string that have been split by the given delimiter(s)
   */
 inline std::vector<std::string> Split(std::string line, std::string delim)
 {
     boost::char_separator<char> separator(delim.c_str());
     boost::tokenizer< boost::char_separator<char> > tokens(line, separator);
     std::vector<std::string> vectorTokens = std::vector<std::string>();
     vectorTokens.assign(tokens.begin(), tokens.end());
     return vectorTokens;
 }
static void _collision_sphere_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {

	const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a);
	const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b);

	SeparatorAxisTest<SphereShapeSW, ConvexPolygonShapeSW, withMargin> separator(sphere_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);

	if (!separator.test_previous_axis())
		return;

	const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();

	const Geometry::MeshData::Face *faces = mesh.faces.ptr();
	int face_count = mesh.faces.size();
	const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
	int edge_count = mesh.edges.size();
	const Vector3 *vertices = mesh.vertices.ptr();
	int vertex_count = mesh.vertices.size();

	// faces of B
	for (int i = 0; i < face_count; i++) {

		Vector3 axis = p_transform_b.xform(faces[i].plane).normal;

		if (!separator.test_axis(axis))
			return;
	}

	// edges of B
	for (int i = 0; i < edge_count; i++) {

		Vector3 v1 = p_transform_b.xform(vertices[edges[i].a]);
		Vector3 v2 = p_transform_b.xform(vertices[edges[i].b]);
		Vector3 v3 = p_transform_a.origin;

		Vector3 n1 = v2 - v1;
		Vector3 n2 = v2 - v3;

		Vector3 axis = n1.cross(n2).cross(n1).normalized();

		if (!separator.test_axis(axis))
			return;
	}

	// vertices of B
	for (int i = 0; i < vertex_count; i++) {

		Vector3 v1 = p_transform_b.xform(vertices[i]);
		Vector3 v2 = p_transform_a.origin;

		Vector3 axis = (v2 - v1).normalized();

		if (!separator.test_axis(axis))
			return;
	}

	separator.generate_contacts();
}
Beispiel #5
0
int foo(void) {
  // Both MSVC and GCC do the ++ after the assignment !
  *buffp = buffer[(*buffa) ++];
  separator(1);
  // Both MSVC and GCC do the ++ before the call to bar !
  // buffb is incremented first in both compilers
  *buffp = bar(buffer[(*buffa) ++] + buffer[(*buffb) ++]);
  separator(2);
  // The +7 must be done before the assignment
  *buffp = buffer[(*buffa) += 7];
  separator(3);
  bar((*buffa) ++) + bar((*buffb) ++);

  separator(4);
  buffer[*buffp + 4] = buffer[(*buffa) ++] + f2(f1((*buffb)++), (*buffc) ++);
  
  return *buffp;
}
Beispiel #6
0
void OptionsDB::GetUsage(std::ostream& os, const std::string& command_line/* = ""*/) const {
    os << UserString("COMMAND_LINE_USAGE") << command_line << "\n";

    int longest_param_name = 0;
    for (const std::map<std::string, Option>::value_type& option : m_options) {
        if (longest_param_name < static_cast<int>(option.first.size()))
            longest_param_name = option.first.size();
    }

    int description_column = 5;
    int description_width = 80 - description_column;

    if (description_width <= 0)
        throw std::runtime_error("The longest parameter name leaves no room for a description.");

    for (const std::map<std::string, Option>::value_type& option : m_options) {
        // Ignore unrecognized options that have not been formally registered
        // with Add().
        if (!option.second.recognized)
            continue;

        if (option.second.short_name)
            os << "-" << option.second.short_name << ", --" << option.second.name << "\n";
        else
            os << "--" << option.second.name << "\n";

        os << std::string(description_column - 1, ' ');

        typedef boost::tokenizer<boost::char_separator<char>> Tokenizer;
        boost::char_separator<char> separator(" \t");
        Tokenizer tokens(UserString(option.second.description), separator);
        int curr_column = description_column;
        for (const Tokenizer::value_type& token : tokens) {
            if (80 < curr_column + token.size()) {
                os << "\n" << std::string(description_column, ' ') << token;
                curr_column = description_column + token.size();
            } else {
                os << " " << token;
                curr_column += token.size() + 1;
            }
        }

        if (option.second.validator) {
            std::stringstream stream;
            stream << UserString("COMMAND_LINE_DEFAULT") << option.second.DefaultValueToString();
            if (80 < curr_column + stream.str().size() + 3) {
                os << "\n" << std::string(description_column, ' ') << stream.str() << "\n";
            } else {
                os << " | " << stream.str() << "\n";
            }
        } else {
            os << "\n";
        }
        os << "\n";
    }
}
Beispiel #7
0
std::vector<std::string> StringToList(const std::string& input_string) {
    std::vector<std::string> retval;
    typedef boost::tokenizer<boost::char_separator<char>> Tokenizer;
    boost::char_separator<char> separator(",");
    Tokenizer tokens(input_string, separator);
    for (const Tokenizer::value_type& token : tokens) {
        retval.push_back(token);
    }
    return retval;
}
Beispiel #8
0
std::string UDir::getNextFilePath()
{
	std::string filePath;
	if(iFileName_ != fileNames_.end())
	{
		filePath = path_+separator()+*iFileName_;
		++iFileName_;
	}
	return filePath;
}
Beispiel #9
0
/**
 * Adds a border & timestamp to the message
 * @param msg
 * @return A new string with the required formatting
 */
QString ScriptOutputDisplay::addTimestamp(const QString &msg) {
  QString separator(75, '-');
  QString timestamped = "%1\n"
                        "%2: %3\n"
                        "%4\n";
  timestamped =
      timestamped.arg(separator, QDateTime::currentDateTime().toString(),
                      msg.trimmed(), separator);
  return timestamped;
}
Beispiel #10
0
void ArSocket::separateHost(const char *rawHost, int rawPort, char *useHost, 
			    size_t useHostSize, int *port)
{
  if (useHost == NULL)
  {
    ArLog::log(ArLog::Normal, "ArSocket: useHost was NULL");
    return;
  }
  if (port == NULL)
  {
    ArLog::log(ArLog::Normal, "ArSocket: port was NULL");
    return;
  }

  useHost[0] = '\0';

  if (rawHost == NULL || rawHost[0] == '\0')
  {
    ArLog::log(ArLog::Normal, "ArSocket: rawHost was NULL or empty");
    return;
  }
  
  ArArgumentBuilder separator(512, ':');
  separator.add(rawHost);

  if (separator.getArgc() <= 0)
  {
    ArLog::log(ArLog::Normal, "ArSocket: rawHost was empty");
    return;
  }
  if (separator.getArgc() == 1)
  {
    snprintf(useHost, useHostSize, separator.getArg(0));
    *port = rawPort;
    return;
  }
  if (separator.getArgc() == 2)
  {
    if (separator.isArgInt(1))
    {
      snprintf(useHost, useHostSize, separator.getArg(0));
      *port = separator.getArgInt(1);
      return;
    }
    else
    {
      ArLog::log(ArLog::Normal, "ArSocket: port given in hostname was not an integer it was %s", separator.getArg(1));
      return;
    }
  }

  // if we get down here there's too many args
  ArLog::log(ArLog::Normal, "ArSocket: too many arguments in hostname %s", separator.getFullString());
  return;
}
Beispiel #11
0
static void
tree_output()
{
     Symbol **symbols, *main_sym;
     int i, num;
     
     /* Collect and sort symbols */
     num = collect_symbols(&symbols, is_var);
     qsort(symbols, num, sizeof(*symbols), compare);
     /* Scan and mark the recursive ones */
     for (i = 0; i < num; i++) {
	  if (symbols[i]->callee)
	       scan_tree(0, symbols[i]);
     }
     
     /* Produce output */
    begin();
    
    if (reverse_tree) {
	 for (i = 0; i < num; i++) {
	      inverted_tree(0, 0, symbols[i]);
	      separator();
	 }
    } else {
	 main_sym = lookup(start_name);
	 if (main_sym) {
	      direct_tree(0, 0, main_sym);
	      separator();
	 } else {
	      for (i = 0; i < num; i++) {
		   if (symbols[i]->callee == NULL)
			continue;
		   direct_tree(0, 0, symbols[i]);
		   separator();
	      }
	 }
    }
    
    end();
    
    free(symbols);
}
Beispiel #12
0
static void _collision_circle_rectangle(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {

	const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a);
	const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b);


	SeparatorAxisTest2D<CircleShape2DSW,RectangleShape2DSW,castA,castB,withMargin> separator(circle_A,p_transform_a,rectangle_B,p_transform_b,p_collector,p_motion_a,p_motion_b,p_margin_A,p_margin_B);

	if (!separator.test_previous_axis())
		return;

	if (!separator.test_cast())
		return;

	const Vector2 &sphere=p_transform_a.elements[2];
	const Vector2 *axis=&p_transform_b.elements[0];
//	const Vector2& half_extents = rectangle_B->get_half_extents();

	if (!separator.test_axis(axis[0].normalized()))
		return;

	if (!separator.test_axis(axis[1].normalized()))
		return;

	Matrix32 binv = p_transform_b.affine_inverse();
	{

		if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv,sphere ) ) )
			return;
	}

	if (castA) {

		Vector2 sphereofs = sphere + p_motion_a;
		if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv, sphereofs) ) )
			return;
	}

	if (castB) {

		Vector2 sphereofs = sphere - p_motion_b;
		if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv, sphereofs) ) )
			return;
	}

	if (castA && castB) {

		Vector2 sphereofs = sphere - p_motion_b + p_motion_a;
		if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv, sphereofs) ) )
			return;
	}

	separator.generate_contacts();
}
Beispiel #13
0
static QString eolDelimiter(const QString& str)
{
  // find the split character
  QString separator('\n');
  if (str.indexOf("\r\n") != -1) {
    separator = "\r\n";
  } else if (str.indexOf('\r') != -1 ) {
    separator = '\r';
  }
  return separator;
}
Beispiel #14
0
std::string MixAll::filterIP(const std::string& addr) {
    std::string separator(",");
    if (addr.find(separator) == std::string::npos) {
        return addr;
    } else {
        std::vector<std::string> ips;
        std::string::size_type previous = 0;
        std::string::size_type current = std::string::npos;
        while ((current = addr.find(separator, previous)) != std::string::npos) {
            std::string ip = addr.substr(previous, current - previous);
            ips.push_back(ip);
            previous = current + 1;

            if (current == addr.find_last_of(separator)) {
                ips.push_back(addr.substr(previous));
                break;
            }
        }

        struct ifaddrs* if_addr = nullptr;
        if (getifaddrs(&if_addr) == -1) {
            // TODO log error.
            std::cout << "Failed to execute getifaddrs()" << std::endl;
        }

        // Choose IP that share the same subnet with current host.
        for (std::vector<std::string>::iterator it = ips.begin(); it != ips.end(); it++) {
            struct sockaddr_in sock;
            inet_pton(AF_INET, it->c_str(), &sock.sin_addr.s_addr);
            struct ifaddrs* p = if_addr;
            while (p != nullptr) {
                if(p->ifa_addr->sa_family == AF_INET) {
                    struct sockaddr_in* ip_addr = (struct sockaddr_in*)p->ifa_addr;
                    struct sockaddr_in* netmask_addr = (struct sockaddr_in*)p->ifa_netmask;
                    if ((ip_addr->sin_addr.s_addr & netmask_addr->sin_addr.s_addr) == (sock.sin_addr.s_addr & netmask_addr->sin_addr.s_addr)) {
                        return *it;
                    }
                }
                p = p->ifa_next;
            }
        }

        // If not found in the previous step, choose a public IP address.
        for (std::string ip : ips) {
            if (is_public_ip(ip)) {
                return ip;
            }
        }

        // Just return the first one and warn.
        std::cout << "Unable to figure out an ideal IP, returning the first candiate." << std::endl;
        return ips[0];
    }
}
Beispiel #15
0
static QString eolDelimiter(const QString &str)
{
    // find the split character
    QString separator(QLatin1Char('\n'));
    if (str.indexOf(QStringLiteral("\r\n")) != -1) {
        separator = QStringLiteral("\r\n");
    } else if (str.indexOf(QLatin1Char('\r')) != -1) {
        separator = QLatin1Char('\r');
    }
    return separator;
}
void HdrCreationManager::align_with_ais() {
	ais=new QProcess(0);
	ais->setWorkingDirectory(qtpfsgui_options->tempfilespath);
	QStringList env = QProcess::systemEnvironment();
	#ifdef WIN32
	QString separator(";");
	#else
	QString separator(":");
	#endif
	env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1"+separator+QCoreApplication::applicationDirPath());
	ais->setEnvironment(env);
	connect(ais, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(ais_finished(int,QProcess::ExitStatus)));
	connect(ais, SIGNAL(error(QProcess::ProcessError)), this, SIGNAL(ais_failed(QProcess::ProcessError)));
	
	#ifdef Q_WS_MAC
	ais->start(QCoreApplication::applicationDirPath()+"/align_image_stack", qtpfsgui_options->align_image_stack_options << (filesToRemove.empty() ? fileList : filesToRemove) );
	#else
	ais->start("align_image_stack", qtpfsgui_options->align_image_stack_options << (filesToRemove.empty() ? fileList : filesToRemove) );
	#endif
}
Beispiel #17
0
std::string getFile(const std::string& path)
{
    auto position = path.rfind(separator());

    if(position == std::string::npos)
    {
        return "";
    }

    return path.substr(position + 1);
}
Beispiel #18
0
std::string stripTrailingSeparators(const std::string& originalPath)
{
    auto path = originalPath;

    while(!path.empty() && path.back() == separator())
    {
        path.resize(path.size() - 1);
    }

    return path;
}
Beispiel #19
0
static int need_full(T_CHAR* ptr)
{
	if (is_roman(ptr)) return 1;
	if (sepcmp(ptr,_TX("RPG"))) return 1;
	while(!separator(*ptr))
	{
		if (*ptr<'0' || *ptr>'9') return 0;
		ptr++;
	}
	return 1;
}
Beispiel #20
0
int main() {
	u32 i;

	TEST_DECLARE(1, "ATOMIC_INIT() + atomic_read()");
	ATOMIC_INIT(&a8);
	ATOMIC_INIT(&a16);
	ATOMIC_INIT(&a32);
	i = atomic_read(&a32);
	if (i) {
		printf("a32 == %u, should be 0\n", i);
		TEST_FAILURE(1);
	} else
		TEST_PASSED(1);
	separator();

	TEST_DECLARE(2, "atomic_set_u32()");
	atomic_set_u32(&a32, 5);
	i = atomic_read(&a32);
	if (i != 5) {
		printf("a32 == %u, should be 5\n", i);
		TEST_FAILURE(2);
	} else
		TEST_PASSED(2);
	separator();

	TEST_DECLARE(3, "atomic_dec_and_test_u32()");
	i = 5;
	while (!atomic_dec_and_test_u32(&a32)) --i;
	if (i != 1) {
		printf("dec and test failed, i=%d\n", i);
		TEST_FAILURE(3);
	} else
		TEST_PASSED(3);
	separator();


	printf("tests failed: %d, tests passed: %d\n",
			TESTS_FAILED, TESTS_PASSED);

	return TESTS_FAILED;
}
Beispiel #21
0
 std::vector<std::string> ParseList(std::string list)
 {
     typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
     std::vector<std::string> result;
     boost::char_separator<char> sep(",{}");
     tokenizer separator(list, sep);
     for(tokenizer::iterator it=separator.begin();it!=separator.end(); ++it)
     {
         result.push_back(TrimString(*it));
     }
     return result;
 }
	bool ExternalFileDataParser::getLineVariableValue(const std::string & line, std::string & value)
	{
		boost::char_separator<char> separator("=");
		boost::tokenizer<boost::char_separator<char>> tokens(line, separator);
		std::vector<std::string> splitLine(std::begin(tokens), std::end(tokens));
		if (2 != splitLine.size())
		{
			return false;
		}
		value = splitLine.back();
		return true;
	}
static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {

	const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a);
	const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b);

	SeparatorAxisTest<CapsuleShapeSW, FaceShapeSW, withMargin> separator(capsule_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);

	Vector3 vertex[3] = {
		p_transform_b.xform(face_B->vertex[0]),
		p_transform_b.xform(face_B->vertex[1]),
		p_transform_b.xform(face_B->vertex[2]),
	};

	if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized()))
		return;

	// edges of B, capsule cylinder

	Vector3 capsule_axis = p_transform_a.basis.get_axis(2) * (capsule_A->get_height() * 0.5);

	for (int i = 0; i < 3; i++) {

		// edge-cylinder
		Vector3 edge_axis = vertex[i] - vertex[(i + 1) % 3];
		Vector3 axis = edge_axis.cross(capsule_axis).normalized();

		if (!separator.test_axis(axis))
			return;

		if (!separator.test_axis((p_transform_a.origin - vertex[i]).cross(capsule_axis).cross(capsule_axis).normalized()))
			return;

		for (int j = 0; j < 2; j++) {

			// point-spheres
			Vector3 sphere_pos = p_transform_a.origin + ((j == 0) ? capsule_axis : -capsule_axis);

			Vector3 n1 = sphere_pos - vertex[i];

			if (!separator.test_axis(n1.normalized()))
				return;

			Vector3 n2 = edge_axis;

			axis = n1.cross(n2).cross(n2);

			if (!separator.test_axis(axis.normalized()))
				return;
		}
	}

	separator.generate_contacts();
}
static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {

	const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a);
	const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW *>(p_b);

	SeparatorAxisTest<CapsuleShapeSW, CapsuleShapeSW, withMargin> separator(capsule_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);

	if (!separator.test_previous_axis())
		return;

	// some values

	Vector3 capsule_A_axis = p_transform_a.basis.get_axis(2) * (capsule_A->get_height() * 0.5);
	Vector3 capsule_B_axis = p_transform_b.basis.get_axis(2) * (capsule_B->get_height() * 0.5);

	Vector3 capsule_A_ball_1 = p_transform_a.origin + capsule_A_axis;
	Vector3 capsule_A_ball_2 = p_transform_a.origin - capsule_A_axis;
	Vector3 capsule_B_ball_1 = p_transform_b.origin + capsule_B_axis;
	Vector3 capsule_B_ball_2 = p_transform_b.origin - capsule_B_axis;

	//balls-balls

	if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_1).normalized()))
		return;
	if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_2).normalized()))
		return;

	if (!separator.test_axis((capsule_A_ball_2 - capsule_B_ball_1).normalized()))
		return;
	if (!separator.test_axis((capsule_A_ball_2 - capsule_B_ball_2).normalized()))
		return;

	// edges-balls

	if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_1).cross(capsule_A_axis).cross(capsule_A_axis).normalized()))
		return;

	if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_2).cross(capsule_A_axis).cross(capsule_A_axis).normalized()))
		return;

	if (!separator.test_axis((capsule_B_ball_1 - capsule_A_ball_1).cross(capsule_B_axis).cross(capsule_B_axis).normalized()))
		return;

	if (!separator.test_axis((capsule_B_ball_1 - capsule_A_ball_2).cross(capsule_B_axis).cross(capsule_B_axis).normalized()))
		return;

	// edges

	if (!separator.test_axis(capsule_A_axis.cross(capsule_B_axis).normalized()))
		return;

	separator.generate_contacts();
}
Beispiel #25
0
int	setenv_void(t_manage *man, char **d_cmd)
{
  int	ret;

  ret = 0;
  if ((ret = my_getenv(man->all_env->my_env, d_cmd[1])) != -1)
    unsetenv_for_setenv(man, d_cmd[1], 1);
  man->all_env->my_env = d_tab_cpy_doc(man->all_env->my_env,
				       separator(d_cmd[1], " ", '='));
  wordtab_end(d_cmd);
  return (0);
}
Beispiel #26
0
void SplitSvtWafer(const Char_t *name = "StarDb/Geometry/svt/svtWafersPosition.20050101.000100.C") {
    TString Top(name);
    Top.ReplaceAll("$STAR/","");
    Top = gSystem->DirName(Top.Data());
    static const Char_t *Barrels[4] = {"InnerBarrel","MiddleBarrel","OuterBarrel","Ssd"};
    static const Char_t *Ladder = "Ladder_";
    static const Char_t *Wafer  = "Wafer_";
    TString Name(name);
    gSystem->ExpandPathName(Name);
    gSystem->Load("libStDb_Tables.so");
    TString cmd(".L ");
    cmd += Name;
    gInterpreter->ProcessLine(cmd);
    St_svtWafersPosition *table = CreateTable();
    cmd.ReplaceAll(".L ",".U ");
    gInterpreter->ProcessLine(cmd);
    table->Print(0,10);
    TString tname = gSystem->BaseName(Name);
    Int_t N = table->GetNRows();
    svtWafersPosition_st *row = table->GetTable();
    TString separator("/");
    for (Int_t i = 0; i < N; i++, row++) {
        //  Int_t Id = ladder + 100*(wafer + 10*layer);
        Int_t Id = row->ID;
        Int_t layer = Id/1000;
        if (layer > 7) layer = 7;
        Id = Id - 1000*layer;
        Int_t wafer = Id/100;
        Int_t ladder = Id%100;
        Int_t barrel = (layer-1)/2;
        TString dir(Top);
        dir += Form("/%s/%s%02i/%s%02i",Barrels[barrel],Ladder,ladder,Wafer,wafer);
        if (gSystem->AccessPathName(dir)) {
            Int_t iok = gSystem->mkdir(dir,kTRUE);
            if (iok > -1) cout << "Make directory " << dir << " done " << endl;
            else         {
                cout << "Make directory " << dir << " failed with " << iok << endl;
            }
        }
        TString ts(dir);
        ts += "/";
        ts += tname;
        ofstream out;
        St_svtWafersPosition *newtable = new St_svtWafersPosition(table->GetName(),1);
        newtable->AddAt(row);
        out.open(ts.Data());
        cout << "Create " << ts << endl;
        newtable->SavePrimitive(out,"");
        out.close();
        delete newtable;
    }
}
Beispiel #27
0
std::string getDirectory(const std::string& originalPath)
{
    auto path = stripTrailingSeparators(originalPath);

    auto position = path.rfind(separator());

    if(position == std::string::npos)
    {
        return "";
    }

    return path.substr(0, position);
}
Beispiel #28
0
void DetectionParams::fixPathString(std::string& instring){

	char  sep = separator();

#ifdef _WIN32
	std::replace(instring.begin(), instring.end(), '/', '\\'); // replace all '/' to '\'
#else
	std::replace(instring.begin(), instring.end(), '\\', '/'); // replace all '\' to '/'
#endif
	if (instring.back() != sep)
		instring.push_back(sep);

}
Beispiel #29
0
 virtual patht& separate() {
     separator_t separator(*this);
     const char_t* chars = 0;
     size_t length = 0;
     clear_parts();
     if ((chars = this->chars(length))) {
         XOS_LOG_MESSAGE_DEBUG("path = \"" << chars << "\"");
         if (!(separator.separate(chars, length))) {
             clear_parts();
         }
     }
     return *this;
 }
Beispiel #30
0
PathName PathName::join(cstring component) const {
    if (component.isNullOrEmpty())
        throw std::logic_error("Empty string for pathname component");
    if (str.isNullOrEmpty())
        return PathName(component);
    char last = str[str.size() - 1];
    for (char c : pathSeparators) {
        if (c == last) {
            auto result = str + component;
            return PathName(result);
        }
    }
    auto result = str + separator() + component;
    return PathName(result);
}