Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape character for '/' as a directory seperator? #45

Open
MelodicsVincent opened this issue Nov 18, 2021 · 2 comments
Open

Escape character for '/' as a directory seperator? #45

MelodicsVincent opened this issue Nov 18, 2021 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@MelodicsVincent
Copy link

With the existing implementation of TestServer.cpp, would it be possible to search for a path that contains a '/' without treating the '/' as a directory seperator? e.g. 'mainWindow/1/2' where '1/2' is the object to find

If not, what modifications could be done to the existsAndVisible function?

@faaxm
Copy link
Owner

faaxm commented Nov 19, 2021

Currently this is not possible as spix simply splits the path at any '/' without the option for an escape character.
This shouldn't be too difficult to fix though.

The conversion from string to spix' path object happens here and would just need to deal with escape characters:

ItemPath::ItemPath(const std::string& path)
{
std::stringstream pathss(path);
while (pathss) {
std::string component;
getline(pathss, component, '/');
if (component.length() > 0) {
m_components.push_back(std::move(component));
}
}
}

And then one would also have to adapt the inverse conversion back to strings:
std::string ItemPath::string() const
{
std::string path;
for (auto& component : m_components) {
if (!path.empty()) {
path += "/";
}
path += component;
}
return path;
}

Last but not least, the unit tests would have to be extended:

TEST(ItemPathTest, InitWithPathString)

@faaxm faaxm added the enhancement New feature or request label Nov 23, 2021
@reubenpuketapu
Copy link

nice!

@faaxm faaxm added the good first issue Good for newcomers label Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants