⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rq_fpml_product_fxsingleleg.c

📁 风险财务控制库 Risk Quantify is an open source financial library, with a focus on managing the risk of fi
💻 C
字号:
/*** rq_fpml_product_fxsingleleg.c**** Written by Brett Hutley - brett@hutley.net**** Copyright (C) 2001 Brett Hutley**** This file is part of the Risk Quantify Library**** Risk Quantify is free software; you can redistribute it and/or** modify it under the terms of the GNU Library General Public** License as published by the Free Software Foundation; either** version 2 of the License, or (at your option) any later version.**** Risk Quantify is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU** Library General Public License for more details.**** You should have received a copy of the GNU Library General Public** License along with Risk Quantify; if not, write to the Free** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include "fpml/rq_fpml_product_fxsingleleg.h"#include <stdlib.h>#include <string.h>/* -- structures --------------------------------------------------- */struct rq_fpml_product_fxsingleleg {    const char *payer_party_id;    const char *receiver_party_id;    double payer_amount;    const char *payer_currency;    double receiver_amount;    rq_date value_date;    const char *receiver_currency;    struct rq_fpml_exchange_rate exchange_rate;};/* -- globals ------------------------------------------------------ */const char *rq_fpml_product_fxsingleleg_product_type = "fxsingleleg";/* -- code --------------------------------------------------------- */intrq_fpml_product_fxsingleleg_write_xml(void *product_data, rq_stream_t output_stream){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)product_data;    int status = 0;    char work_buf[20];    /* */    /**     * \todo need to work out status properly     */    rq_stream_write_string(output_stream, "<fxSingleLeg>");    rq_stream_write_string(output_stream, "<exchangedCurrency1>");    rq_stream_write_string(output_stream, "<payerPartyReference href=\"");    rq_stream_write_string(output_stream, p->payer_party_id);    rq_stream_write_string(output_stream, "\"/>");    rq_stream_write_string(output_stream, "<receiverPartyReference href=\"");    rq_stream_write_string(output_stream, p->receiver_party_id);    rq_stream_write_string(output_stream, "\"/>");        rq_stream_write_string(output_stream, "<paymentAmount>");     rq_stream_write_string(output_stream, "<currency>");    rq_stream_write_string(output_stream, p->payer_currency);    rq_stream_write_string(output_stream, "</currency>");    rq_stream_write_string(output_stream, "<amount>");    rq_stream_write_string(output_stream, "</amount>");       rq_stream_write_string(output_stream, "</paymentAmount>");     rq_stream_write_string(output_stream, "</exchangedCurrency1>");     rq_stream_write_string(output_stream, "<exchangedCurrency2>");       rq_stream_write_string(output_stream, "<payerPartyReference href=\"");    rq_stream_write_string(output_stream, "\"/>");    rq_stream_write_string(output_stream, "<receiverPartyReference href=\"");    rq_stream_write_string(output_stream, "\"/>");    rq_stream_write_string(output_stream, "<paymentAmount>");      rq_stream_write_string(output_stream, "<currency>");    rq_stream_write_string(output_stream, p->receiver_currency);    rq_stream_write_string(output_stream, "</currency>");    rq_stream_write_string(output_stream, "<amount>");    rq_stream_write_string(output_stream, "</amount>");    rq_stream_write_string(output_stream, "</paymentAmount>");     rq_stream_write_string(output_stream, "</exchangedCurrency2>");     rq_stream_write_string(output_stream, "<valueDate>");    rq_stream_write_string(output_stream, "</valueDate>");    rq_stream_write_string(output_stream, "<exchangeRate>");    rq_stream_write_string(output_stream, "<quotedCurrencyPair>");    rq_stream_write_string(output_stream, "<currency1>");    rq_stream_write_string(output_stream, "</currency1>");    rq_stream_write_string(output_stream, "<currency2>");    rq_stream_write_string(output_stream, "</currency2>");    rq_stream_write_string(output_stream, "<quoteBasis>");    rq_stream_write_string(output_stream, "</quoteBasis>");    rq_stream_write_string(output_stream, "</quotedCurrencyPair>");                rq_stream_write_string(output_stream, "<rate>");    rq_stream_write_string(output_stream, "</rate>");    rq_stream_write_string(output_stream, "</exchangeRate>");      rq_stream_write_string(output_stream, "</fxSingleLeg>");      return status;}static void rq_fpml_product_fxsingleleg_free(void *product_data){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)product_data;    if (p->payer_party_id)        free((char *)p->payer_party_id);    if (p->receiver_party_id)        free((char *)p->receiver_party_id);    if (p->payer_currency)        free((char *)p->payer_currency);    if (p->receiver_currency)        free((char *)p->receiver_currency);    rq_fpml_exchange_rate_clear(&p->exchange_rate);    free(p);}rq_fpml_product_t rq_fpml_product_fxsingleleg_alloc(){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)calloc(1, sizeof(struct rq_fpml_product_fxsingleleg));    rq_fpml_product_t product = _rq_fpml_product_alloc(        rq_fpml_product_fxsingleleg_product_type,        p,        rq_fpml_product_fxsingleleg_write_xml,        rq_fpml_product_fxsingleleg_free        );    return product;}const char *rq_fpml_product_fxsingleleg_get_payer_party_id(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return p->payer_party_id;}void rq_fpml_product_fxsingleleg_set_payer_party_id(rq_fpml_product_t pr, const char *payer_party_id){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    if (p->payer_party_id)        free((char *)p->payer_party_id);    p->payer_party_id = (const char *)strdup(payer_party_id);}const char *rq_fpml_product_fxsingleleg_get_receiver_party_id(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return p->receiver_party_id;}void rq_fpml_product_fxsingleleg_set_receiver_party_id(rq_fpml_product_t pr, const char *receiver_party_id){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    if (p->receiver_party_id)        free((char *)p->receiver_party_id);    p->receiver_party_id = (const char *)strdup(receiver_party_id);}double rq_fpml_product_fxsingleleg_get_payer_amount(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return p->payer_amount;}void rq_fpml_product_fxsingleleg_set_payer_amount(rq_fpml_product_t pr, double payer_amount){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    p->payer_amount = payer_amount;}const char *rq_fpml_product_fxsingleleg_get_payer_currency(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return p->payer_currency;}void rq_fpml_product_fxsingleleg_set_payer_currency(rq_fpml_product_t pr, const char *payer_currency){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    if (p->payer_currency)        free((char *)p->payer_currency);    p->payer_currency = (const char *)strdup(payer_currency);}double rq_fpml_product_fxsingleleg_get_receiver_amount(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return p->receiver_amount;}void rq_fpml_product_fxsingleleg_set_receiver_amount(rq_fpml_product_t pr, double receiver_amount){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    p->receiver_amount = receiver_amount;}const char *rq_fpml_product_fxsingleleg_get_receiver_currency(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return p->receiver_currency;}void rq_fpml_product_fxsingleleg_set_receiver_currency(rq_fpml_product_t pr, const char *receiver_currency){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    if (p->receiver_currency)        free((char *)p->receiver_currency);    p->receiver_currency = (const char *)strdup(receiver_currency);}rq_date rq_fpml_product_fxsingleleg_get_value_date(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return p->value_date;}void rq_fpml_product_fxsingleleg_set_value_date(rq_fpml_product_t pr, rq_date value_date){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    p->value_date = value_date;}struct rq_fpml_exchange_rate *rq_fpml_product_fxsingleleg_get_exchange_rate(rq_fpml_product_t pr){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    return &p->exchange_rate;}void rq_fpml_product_fxsingleleg_set_exchange_rate(rq_fpml_product_t pr, const char *currency1, const char *currency2, enum rq_quote_basis quote_basis, double rate){    struct rq_fpml_product_fxsingleleg *p =         (struct rq_fpml_product_fxsingleleg *)_rq_fpml_product_get_product_data(pr);    rq_fpml_exchange_rate_fill(&p->exchange_rate, currency1, currency2, quote_basis, rate);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -