~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/srv/wax/shl/XmlMime.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// ---------------------------------------------------------------------------
2
2
// - XmlMime.cpp                                                             -
3
 
// - afnix:wax module - xml mime class implementation                        -
 
3
// - afnix:wax service - xml mime class implementation                       -
4
4
// ---------------------------------------------------------------------------
5
5
// - This program is free software;  you can redistribute it  and/or  modify -
6
6
// - it provided that this copyright notice is kept intact.                  -
11
11
// - the copyright holder be liable for any  direct, indirect, incidental or -
12
12
// - special damages arising in any way out of the use of this software.     -
13
13
// ---------------------------------------------------------------------------
14
 
// - copyright (c) 1999-2007 amaury darsch                                   -
 
14
// - copyright (c) 1999-2011 amaury darsch                                   -
15
15
// ---------------------------------------------------------------------------
16
16
 
17
 
#include "Input.hpp"
18
17
#include "XmlMime.hpp"
19
18
#include "Runnable.hpp"
20
19
#include "QuarkZone.hpp"
45
44
    d_mime = XML_MIME_TYPE;
46
45
  }
47
46
 
 
47
  // create a xml mime by document
 
48
 
 
49
  XmlMime::XmlMime (const XmlDocument& xdoc) : XmlDocument (xdoc) {
 
50
    d_mime = XML_MIME_TYPE;
 
51
  }
 
52
 
48
53
  // create a xml mime document by name and stream
49
54
 
50
 
  XmlMime::XmlMime (const String& name, Input* is) : XmlDocument (name, is) {
 
55
  XmlMime::XmlMime (const String& name, 
 
56
                    InputStream* is) : XmlDocument (name, is) {
 
57
    d_mime = XML_MIME_TYPE;
 
58
  }
 
59
 
 
60
  // create a xml mime document by name and xml root node
 
61
 
 
62
  XmlMime::XmlMime (const String& name, XmlRoot* root) : 
 
63
    XmlDocument (name, root) {
51
64
    d_mime = XML_MIME_TYPE;
52
65
  }
53
66
 
75
88
 
76
89
  // write a node to an output stream
77
90
 
78
 
  void XmlMime::write (Output& os) const {
 
91
  void XmlMime::write (OutputStream& os) const {
79
92
    rdlock ();
80
93
    try {
81
94
      // get the xml root node
98
111
  Object* XmlMime::mknew (Vector* argv) {
99
112
    // get the number of arguments
100
113
    long argc = (argv == nilp) ? 0 : argv->length ();
101
 
    // check for o argument
 
114
    // check for 0 argument
102
115
    if (argc == 0) return new XmlMime;
103
116
    // check for 1 argument
104
117
    if (argc == 1) {
105
 
      String name = argv->getstring (0);
106
 
      return new XmlMime (name);
 
118
      // get the object and check
 
119
      Object* obj = argv->get (0);
 
120
      // check for a string
 
121
      String* sobj = dynamic_cast <String*> (obj);
 
122
      if (sobj != nilp) return new XmlMime (*sobj);
 
123
      // check for a xml document
 
124
      XmlDocument* xdoc = dynamic_cast <XmlDocument*> (obj);
 
125
      if (xdoc != nilp) return new XmlMime (*xdoc);
 
126
      // invalid type
 
127
      throw Exception ("type-error", "invalid object with XmlMime constructor",
 
128
                       Object::repr (obj));
107
129
    }
108
130
    // check for 2 arguments
109
131
    if (argc == 2) {
112
134
      // get the object and check
113
135
      Object* obj = argv->get (1);
114
136
      // check for an input stream
115
 
      Input* is = dynamic_cast <Input*> (obj);
 
137
      InputStream* is = dynamic_cast <InputStream*> (obj);
116
138
      if (is != nilp) return new XmlMime (name, is);
 
139
      // check for xml root node
 
140
      XmlRoot* root = dynamic_cast <XmlRoot*> (obj);
 
141
      if (root != nilp) return new XmlMime (name, root);
 
142
      // invalid object
117
143
      throw Exception ("type-error", 
118
144
                       "invalid object with document constructor",
119
145
                       Object::repr (obj));