Writer: add SetDoublePrecision to control number of significant digits

Writing a double to an OutputStream current prints at most 6 significant
digits (according to the C standard).

The function SetDoublePrecision(), added to the Writer classes
can be used to fluently set the precision, i.e. the number of
significant digits to use for writing the double:

  Writer<...> writer(...);
  d.Accept(writer.SetDoublePrecision(12));
Writer: add Double(d,precision) for one-shot double output

As proposed in other patches, it is convenient to pass a user-defined
precision for the (programmatic) output of a single double value
to an OutputStream.

This patch adds an additional overload with an explicit precision
argument to the (Pretty)Writer class templates.
DoublePrecision: add a unit test for the precision handling
GenericDocument: forward allocator to GenericReader

Fixes http://code.google.com/p/rapidjson/issues/detail?id=72.
optionally accept arbitrary root elements

Although RFC 4627 requires root elements to be either an object or an
array, sometimes the plain (de)serialisation of an arbitrary value is
needed.

This patch adds a new function AcceptAnyRoot(bool) to
  * GenericReader
  * GenericDocument
  * (Pretty)Writer
to optionally accept such arbitrary root elements for reading/parsing
and writing.

Example:
{
  Document d;
  d.AcceptAnyRoot().Parse<0>( "\"foo\"" );
  assert(!d.HasParseError());
  assert(d.IsString());

  FileStream s(stdout);
  PrettyWriter<FileStream> writer(s);
  d.Accept( writer.AcceptAnyRoot() );
}

This functionality is guarded behind the preprocessor symbol
RAPIDJSON_ACCEPT_ANY_ROOT.
AcceptAnyRoot: add unit tests
GenericDocument::Accept: deep-copy strings, if needed

Instead of always just shallowly referencing the potentially allocated
strings when calling the Handler::String function, request a copy in
case the string has been allocated from an Allocator before.

This is necessary to avoid double free()s of the string memory,
especially when using the Handler to create a deep copy of a Value.
GenericValue: add copy constructor and CopyFrom

To allow deep copying from an existing GenericValue, an
explicit "copy constructor" (with required Allocator param)
and an "CopyFrom" assignment function are added.

  Document d; Document::AllocatorType& a = d.GetAllocator();
  Value v1("foo");
  // Value v2(v1); // not allowed

  Value v2(v1,a);                             // make a copy
  RAPIDJSON_ASSERT(v1.IsString());            // v1 untouched
  d.SetArray().PushBack(v1,a).PushBack(v2,a);
  RAPIDJSON_ASSERT(v1.Empty() && v2.Empty());

  v2.CopyFrom(d,a);                           // copy whole document
  RAPIDJSON_ASSERT(d.IsArray() && d.Size());  // d untouched
  v1.SetObject().AddMember( "array", v2, a );
  d.PushBack(v1,a);

Additionally, the Handler implementation in GenericDocument is made
private again, restricting access to GenericReader and GenericValue.
valuetest: add deep copy unit test

This commit adds some simple tests for the deep-copying
of values, either based on the explicit constructor, or
the CopyFrom function.

It uses the CrtAllocator to test for possible double-free
errors due to insufficient copying.
Document::AcceptAnyRoot: actually store parameter

And consistently add documentation to all AcceptAnyRoot()
functions.
Merge branch 'value-copy-from' into for-upstream
Merge branch 'accept-any-root' into for-upstream
Merge branch 'double-precision' into for-upstream
Merge branch 'for-upstream' into github
README.md: explicitly list significant enhancements