ctelroy / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

Writer does not have any virtual methods #87

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  Create a PrettyWriter
2.  Pass PrettyWriter into a method which takes a Writer

What is the expected output? What do you see instead?
I would expect that since PrettyWriter is a subclass of Writer, methods with 
the same name would be called on PrettyWriter.  But since Writer has no virtual 
methods, the Writer methods are called instead of the PrettyWriter 

What version of the product are you using? On what operating system?
0_11

Please provide any additional information below.
Examples that should be virtual in Writer.h:
  StartObject()
  WriteObject()
  String()
  StartArray()
  EndArray()

ext.  Any method in PrettyWriter that is a duplicate of Writer.  This seems 
like it would even generate a warning the in the compiler. 

Original issue reported on code.google.com by kennfda...@gmail.com on 8 Aug 2013 at 6:10

GoogleCodeExporter commented 8 years ago
The design of rapidjson prevents polymorphism due to performance consideration.

However, if you would like to, you can create a base class with virtual 
functions and wrap the current writer/prettywriter classes as its derived 
classes.

The accept function should still work.

Original comment by milo...@gmail.com on 12 Aug 2013 at 8:52

GoogleCodeExporter commented 8 years ago

Original comment by milo...@gmail.com on 20 Jun 2014 at 11:20