Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 05-17-2006
dthompson dthompson is offline
Registered User
 
Name: Don Thompson
Organization: Digital Federal Credit Union
Project: credit card fraud monitoring
 
Join Date: Aug 2005
Location: south shore mass
Posts: 10
php ice interface struct initialization

Hi,
Is there a way to add a constructor to initialize a struct instance. I need to pass this as a parameter as shown in the code fragment.

thanks,
Don

// section from CU.ice:
module CU
{
// Transaction, becomes CU_Transaction
struct Transaction {
string posteff;
int account;
...
}
bool transfer(Transaction from, Transaction to) throws PostError;
}

// testing usage of transfer from PHP
$xferfrom = array ("posteff" => "2006-05-15","account" => (int)12345, "suffix" => (int)51, "accttype" => "S","mnemonic" => "SDT", "amount" => (double)12345.67);

$fromshr = new CU_Transaction($xferfrom);
// constructor doesn't work, so initialize the hard way
$fromshr->posteff = '2006-05-16';
$fromshr->account = 2;
$fromshr->accttype = 83;
$fromshr->suffix = 1;
$fromshr->mnemonic = 'SWX';
$fromshr->amount = 100;
$fromshr->descr = 'xfer test from php';
// now post the transfer
$ok = $gcu->transfer($fromshr, $toshr);
// it works!, PHP and Ice are Great!
__________________
Don Thompson
Digital Federal Credit Union
www.dcu.org
Ice Project: credit union core processing prototype which may expand to open source project.
Current Environment:
Debian Linux Sarge,
mysql 4.1.11-Debian,
mysql++ v 2.1.0.beta1,
qt3 v 3.3.4,
Ice-3.0.1
IcePHP-3.0.1
Server: c++ using mysql++ to access mysql db, with Ice interfaces.
Desktop Client: c++ using qt3, Ice interfaces to Server
Home Banking Client: Python using IcePy interface to Server
Currently using PHP Client
Reply With Quote
  #2 (permalink)  
Old 05-17-2006
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 976
Hi Don,

The Slice-to-PHP mapping doesn't currently define a "one shot" constructor that accepts values for all data members. We probably should, but I don't think it would do what you want. It looks like what you want is a constructor that accepts an array containing values for each of the data members. This is something you could do yourself fairly easily:
Code:
$fromshr = new CU_Transaction;
foreach($xferfrom as $key => $value)
    $fromshr->$key = $value;
Hope that helps,
- Mark
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
python: Ice.initialize with initialization data fails hiasl Bug Reports 1 02-05-2007 09:59 AM
ICE and COM initialization question gasproni Help Center 1 11-11-2005 07:43 AM
Feature Request: generate constructors with parameter for initialization DeepDiver Comments 2 01-04-2005 11:05 AM
Initialization of IceSSL rhochmuth Help Center 1 05-13-2004 08:05 PM
class with operations, Initialization StuartA Help Center 6 02-22-2004 07:58 PM


All times are GMT -4. The time now is 11:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.