Summary:
This API is analogous to c++ substr. It returns a Eina_Strbuf with
substring of passed buf.
Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
Reviewers: cedric
Reviewed By: cedric
Differential Revision: https://phab.enlightenment.org/D3224
eina_str_tolower((char **)&(buf->buf));
}
+EAPI Eina_Strbuf *
+eina_strbuf_substr_get(Eina_Strbuf *buf, size_t pos, size_t len)
+{
+ char *str;
+
+ if ((!buf) || ((pos + len) > buf->len))
+ return NULL;
+
+ str = calloc(0, len + 1);
+
+ strncpy(str,((char *)(buf->buf)) + pos, len);
+
+ return eina_strbuf_manage_new(str);
+}
+
/* Unicode */
#include "eina_strbuf_template_c.x"
EAPI void eina_strbuf_tolower(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
/**
+ * @brief Obtain substring from the src.
+ *
+ * @param buf the src string.
+ * @param pos the position in the source string from which the substring
+ * should be created. The first character is denoted by a
+ * value of 0 (not 1).
+ * @param len the length from pos that should be copied to substring.
+ *
+ * This function creates a Eina_Strbuf which is a substring of buf which
+ * is passed from pos position with len length.
+ */
+EAPI Eina_Strbuf * eina_strbuf_substr_get(Eina_Strbuf *buf, size_t pos, size_t len) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+
+/**
* @}
*/