Source

fantomongo / fan / bson / BsonReader.fan

Diff from to

fan/bson/BsonReader.fan

         case Bson.UNDEFINED:
         case Bson.NULL:
           remaining -= readNull(ins, bson)
-        // case Bson.REGEX:
-          // remaining = readRegex(ins, bson)
+        case Bson.REGEX:
+          remaining = readRegex(ins, bson)
         case Bson.CODE_W_SCOPE:
           remaining -= readCode(ins, bson)
         case Bson.NUMBER_LONG:
     bson[name] = MaxKey() // todo - figure this out
     return (name.size + 1)
   }
+
+  static private Int readRegex(InStream ins, Str:Obj? bson)
+  {
+    name := readCStr(ins)
+    pattern := readCStr(ins)
+    flags := readCStr(ins)   // TODO: implement flags support in Fantom
+    bson[name] = Regex.fromStr(pattern)
+    regexlen := pattern.size + 1 + flags.size + 1
+    return (name.size + 1 + regexlen)
+  }
   
 }