fish-shell/src/wcstringutil.h

24 lines
937 B
C
Raw Normal View History

// Helper functions for working with wcstring.
#ifndef FISH_WCSTRINGUTIL_H
#define FISH_WCSTRINGUTIL_H
2015-07-25 23:14:25 +08:00
#include <string>
#include <utility>
#include "common.h"
2016-06-06 12:30:24 +08:00
/// @typedef wcstring_range represents a range in a wcstring.
/// The first element is the location, the second is the count.
typedef std::pair<wcstring::size_type, wcstring::size_type> wcstring_range;
/// wcstring equivalent of wcstok(). Supports NUL. For convenience and wcstok() compatibility, the
/// first character of each token separator is replaced with NUL.
2016-06-06 12:30:24 +08:00
/// @return Returns a pair of (pos, count).
/// This will be (npos, npos) when it's done. In the form of (pos, npos)
/// when the token is already known to be the final token.
/// @note The final token may not necessarily return (pos, npos).
wcstring_range wcstring_tok(wcstring& str, const wcstring& needle,
wcstring_range last = wcstring_range(0, 0));
#endif