DBJSON.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. Copyright (C) 2007-2009 Stig Brautaset. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. * Redistributions of source code must retain the above copyright notice, this
  6. list of conditions and the following disclaimer.
  7. * Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. * Neither the name of the author nor the names of its contributors may be used
  11. to endorse or promote products derived from this software without specific
  12. prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  14. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  17. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  20. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  22. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #import <Foundation/Foundation.h>
  25. #import "DBJsonParser.h"
  26. #import "DBJsonWriter.h"
  27. /**
  28. @brief Facade for DBJsonWriter/DBJsonParser.
  29. Requests are forwarded to instances of DBJsonWriter and DBJsonParser.
  30. */
  31. @interface DBJSON : DBJsonBase <DBJsonParser, DBJsonWriter> {
  32. @private
  33. DBJsonParser *jsonParser;
  34. DBJsonWriter *jsonWriter;
  35. }
  36. /// Return the fragment represented by the given string
  37. - (id)fragmentWithString:(NSString*)jsonrep
  38. error:(NSError**)error;
  39. /// Return the object represented by the given string
  40. - (id)objectWithString:(NSString*)jsonrep
  41. error:(NSError**)error;
  42. /// Parse the string and return the represented object (or scalar)
  43. - (id)objectWithString:(id)value
  44. allowScalar:(BOOL)x
  45. error:(NSError**)error;
  46. /// Return JSON representation of an array or dictionary
  47. - (NSString*)stringWithObject:(id)value
  48. error:(NSError**)error;
  49. /// Return JSON representation of any legal JSON value
  50. - (NSString*)stringWithFragment:(id)value
  51. error:(NSError**)error;
  52. /// Return JSON representation (or fragment) for the given object
  53. - (NSString*)stringWithObject:(id)value
  54. allowScalar:(BOOL)x
  55. error:(NSError**)error;
  56. @end