Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to finding the type of Php::Value #313

Open
ond1 opened this issue Jan 30, 2017 · 0 comments
Open

Best way to finding the type of Php::Value #313

ond1 opened this issue Jan 30, 2017 · 0 comments

Comments

@ond1
Copy link

ond1 commented Jan 30, 2017

Hi,

Just need some guidance on the best way to find the type of a Php::Value please.

Here is a snippet of old code in used with zend:

zval *zvalue =....;
switch (Z_TYPE_P(zvalue)) {
case IS_BOOL:
.....
break;
case IS_LONG:
......
break;
case IS_STRING:
.....
break;
case IS_NULL:
......
break;
case IS_DOUBLE:
....

To do the equivalent in In PHP-CPP I have started by using Php:Type. But I am not sure if this is the best approach.
Php::Value PHP_SaxonProcessor::createAtomicValue(Php::Parameters &params)
{

Php::Type _type = ((Php::Value)params[0]).type();
......

switch (_type) {
        case Type::False:
    case Type::True:
            xdmValue = proc->makeBooleanValue((bool)param[0]);
        	php_atomicValue = new PHP_XdmAtomicValue(xdmValue);
	return Php::Object("Saxon\\XdmAtomicValue", php_atomicValue);
        case Type::Numeric:
	 xdmValue = proc->makeIntegerValue((int)param[0]);
        	php_atomicValue = new PHP_XdmAtomicValue(xdmValue);
	return Php::Object("Saxon\\XdmAtomicValue", php_atomicValue);
        case Type::String:

...

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant