/*
     * This method processes a block of rows in a single invocation.
     *
     * The inputs are retrieved via arg_reader
     * The outputs are returned via arg_writer
     */
    virtual void processBlock(ServerInterface &srvInterface,
                              BlockReader &arg_reader,
                              BlockWriter &res_writer)
    {

        // While we have inputs to process
        do {
            if (arg_reader.getStringRef(0).isNull()) {
                res_writer.getStringRef().setNull();
            }
            else {

                string data = arg_reader.getStringRef(0).str();
                string path = arg_reader.getStringRef(1).str();
                ResponseInfo response = XMLFunctions::xpath(data, path, srvInterface);
                if ((int) response.size() < arg_reader.getIntRef(2)) {
                    res_writer.getStringRef().setNull();
                } else if ((int) response.size() > 0) {
                    res_writer.getStringRef().copy( response[arg_reader.getIntRef(2)-1]);
                } else {
                    res_writer.getStringRef().setNull();
                }
            }

            res_writer.next();
        } while (arg_reader.next());
    }
Ejemplo n.º 2
0
			virtual void processBlock(ServerInterface &srvInterface,
				            BlockReader &arg_reader,
					        BlockWriter &res_writer) {
				if (arg_reader.getNumCols() != 1)
					vt_report_error(0, "Function only accept 1 arguments, but %zu provided", arg_reader.getNumCols());

				// While we have inputs to process
				do {
					const vint num = arg_reader.getIntRef(0);

					// check for valid month number
					if (num > BILLION)
					vt_report_error(0, "ERROR: OUT OF RANGE");

					res_writer.getStringRef().copy(spell_out(num));
					res_writer.next();
				} while (arg_reader.next());					
			}