summaryrefslogtreecommitdiff
path: root/src/upb_strstream.h
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-02-13 12:59:54 -0800
committerJoshua Haberman <joshua@reverberate.org>2011-02-13 12:59:54 -0800
commit6bdbb45e88e7b88b294dfb6e4cb493cbc3c8cf74 (patch)
tree0e00246fb124ebdf6a2210c816704c1d840e2138 /src/upb_strstream.h
parentee84a7da167d2211066c4a663d41febdf9544438 (diff)
Merged core/ and stream/ -> src/. The split wasn't worth it.
Diffstat (limited to 'src/upb_strstream.h')
-rw-r--r--src/upb_strstream.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/upb_strstream.h b/src/upb_strstream.h
new file mode 100644
index 0000000..1a8792b
--- /dev/null
+++ b/src/upb_strstream.h
@@ -0,0 +1,65 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * This file contains upb_bytesrc and upb_bytesink implementations for
+ * upb_string.
+ *
+ * Copyright (c) 2009-2010 Joshua Haberman. See LICENSE for details.
+ */
+
+#ifndef UPB_STRSTREAM_H
+#define UPB_STRSTREAM_H
+
+#include "upb_stream.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* upb_stringsrc **************************************************************/
+
+struct _upb_stringsrc {
+ upb_bytesrc bytesrc;
+ upb_string *str;
+ upb_strlen_t offset;
+};
+typedef struct _upb_stringsrc upb_stringsrc;
+
+// Create/free a stringsrc.
+void upb_stringsrc_init(upb_stringsrc *s);
+void upb_stringsrc_uninit(upb_stringsrc *s);
+
+// Resets the stringsrc to a state where it will vend the given string. The
+// stringsrc will take a reference on the string, so the caller need not ensure
+// that it outlives the stringsrc. A stringsrc can be reset multiple times.
+void upb_stringsrc_reset(upb_stringsrc *s, upb_string *str);
+
+// Returns the upb_bytesrc* for this stringsrc. Invalidated by reset above.
+upb_bytesrc *upb_stringsrc_bytesrc(upb_stringsrc *s);
+
+
+/* upb_stringsink *************************************************************/
+
+struct upb_stringsink;
+typedef struct upb_stringsink upb_stringsink;
+
+// Create/free a stringsrc.
+upb_stringsink *upb_stringsink_new();
+void upb_stringsink_free(upb_stringsink *s);
+
+// Gets a string containing the data that has been written to this stringsink.
+// The caller does *not* own any references to this string.
+upb_string *upb_stringsink_getstring(upb_stringsink *s);
+
+// Clears the internal string of accumulated data, resetting it to empty.
+void upb_stringsink_reset(upb_stringsink *s);
+
+// Returns the upb_bytesrc* for this stringsrc. Invalidated by reset above.
+upb_bytesink *upb_stringsrc_bytesink();
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback