]> git.saurik.com Git - cycript.git/blobdiff - Code.hpp
CYPoolCode should simply take an std::istream &.
[cycript.git] / Code.hpp
diff --git a/Code.hpp b/Code.hpp
new file mode 100644 (file)
index 0000000..324c00f
--- /dev/null
+++ b/Code.hpp
@@ -0,0 +1,52 @@
+/* Cycript - Optimizing JavaScript Compiler/Runtime
+ * Copyright (C) 2009-2013  Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cycript is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cycript is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cycript.  If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#ifndef CODE_HPP
+#define CODE_HPP
+
+#include <iostream>
+
+#include "String.hpp"
+
+class CYStream :
+    public std::istream
+{
+  private:
+    class CYBuffer :
+        public std::streambuf
+    {
+      public:
+        CYBuffer(const char *start, const char *end) {
+            setg(const_cast<char *>(start), const_cast<char *>(start), const_cast<char *>(end));
+        }
+    } buffer_;
+
+  public:
+    CYStream(const char *start, const char *end) :
+        std::istream(&buffer_),
+        buffer_(start, end)
+    {
+    }
+};
+
+CYUTF8String CYPoolCode(CYPool &pool, std::istream &stream);
+
+#endif//CODE_HPP