Astro-SkyCat

 view release on metacpan or  search on metacpan

SkyCat.xs  view on Meta::CPAN

AstroCatalog::id_col()

int
AstroCatalog::ra_col()

int
AstroCatalog::dec_col()

int
AstroCatalog::x_col()

int
AstroCatalog::y_col()

int
AstroCatalog::is_tcs()

int
AstroCatalog::isWcs()

int
AstroCatalog::isPix()

double
AstroCatalog::equinox()

void
AstroCatalog::feedback( f )
  FILE * f


int
AstroCatalog::status()

const char *
AstroCatalog::name()

const char *
AstroCatalog::longName()

const char *
AstroCatalog::shortName()

const char *
AstroCatalog::servType()

const char *
AstroCatalog::url()

int
AstroCatalog::numCols()

# This is the same as AstroQuery::colNames

void
AstroCatalog::colNames()
 PREINIT:
  int i;
  int len;
  char ** names;
 PPCODE:
  names = THIS->colNames();
  for (i = 0; i < THIS->numCols(); i++) {
    len = strlen( *names );
    XPUSHs(sv_2mortal(newSVpv( *names++, len)));
  }



const char *
AstroCatalog::colName( col )
  int col

int
AstroCatalog::colIndex( colName )
  const char * colName

int
AstroCatalog::hasCol( name )
  const char * name

int
AstroCatalog::more()

const char *
AstroCatalog::tmpfile()

# The image is either a URL or a Astro::SkyCat::Query object
# Take an SV as the arg

int
AstroCatalog::getImage( arg  )
  SV * arg;
 PREINIT:
  const char * url;
  AstroQuery * q;
 CODE:
  /* See if we have a blessed Astro::SkyCat::Query object */
  if (sv_derived_from(arg, "Astro::SkyCat::Query")) {
    IV tmp = SvIV((SV*)SvRV(arg));
    q = INT2PTR(AstroQuery * ,tmp);

    /* run the method */
    RETVAL = THIS->getImage( *q );

  } else {

    /* A char * */
    char * url = (char *)SvPV(arg,PL_na); 

    RETVAL = THIS->getImage( url );

  }


const char *
AstroCatalog::getError()

void
AstroCatalog::clearError()

void
AstroCatalog::DESTROY();

     
MODULE = Astro::SkyCat   PACKAGE = Astro::SkyCat::Query


AstroQuery *
AstroQuery::new()


# Can be used to set or return
# A pain since we cant use typemaps

# ID is tricky since when it is used as an accessor
# it returns a char and when it is used to set the ID
# it returns an int
# Can either break the interface and have setid, getid
# or we have to use PPCODE to handle with the return value
# Essentially means we are doing everything by hand

void
AstroQuery::id( ... )
 PREINIT:
  int retint;
  const char * retchar;
  const char * inchar;
 PPCODE:
  if (items == 2) {
    /* Setting the attribute */
    inchar = (const char *)SvPV(ST(1),PL_na);  
    retint = THIS->id( inchar );
    PUSHs(sv_2mortal( newSViv( retint )));

  } else {
    /* returning the attribute */
    retchar = THIS->id();
    PUSHs(sv_2mortal( newSVpv(retchar, strlen(retchar))));
  }

# Pos returns an int when used to set and the pos object
# when used to retrieve
# We must bless this ourselves since we can not use
# a typemap

void
AstroQuery::pos( ... )
 PREINIT:
  int retint; 
  WorldOrImageCoords retwc;
  const WorldOrImageCoords * inwc;
  const WorldOrImageCoords * inwc2;
  SV * retsv;
 PPCODE:
  if (items >= 2) {
    /* Setting the attribute - unfortunately it has to be an object */
    inwc = SvToWorldOrImageCoords( ST(1) );

    if (items == 2) {
									 
      /* We might need to inc ref count here in case we free the WCS
	 object before this command completes. Problem is how to dec
	 the ref count when this object disappears */
      retint = THIS->pos( *inwc );

    } else {
    
      /* We have 2 arguments so need to read it */
      inwc2 = SvToWorldOrImageCoords( ST(2) );      

      retint = THIS->pos( *inwc, *inwc2 );

    }

    /* store the result */
    PUSHs(sv_2mortal( newSViv( retint )));

  } else {
    /* returning the attribute */
    retwc = THIS->pos();
    retsv = sv_newmortal(); /* create the return sv */
    sv_setref_pv(retsv, "Astro::SkyCat::WorldOrImageCoords", (void *)&retwc) ;
    PUSHs( retsv );
  }


# Technically these accessors return void when used
# to set a value. Here they return a pseudo-double
# No-one should really care unless it breaks something

double
AstroQuery::width( ... )
 PREINIT:
  double width;
 CODE:
  if (items == 2) {
    width = (double)SvNV( ST(1) );
    THIS->width( width );   
  }
  RETVAL = THIS->width();
 OUTPUT:
  RETVAL

double
AstroQuery::height( ... )
 PREINIT:
  double height;
 CODE:
  if (items == 2) {
    height = (double)SvNV( ST(1) );
    THIS->height( height );   
  }
  RETVAL = THIS->height();
 OUTPUT:

SkyCat.xs  view on Meta::CPAN

int
QueryResult::getPos( row, pos)
  int row
  WorldOrImageCoords * pos;
 CODE:
  RETVAL = THIS->getPos( row, *pos);
 OUTPUT:
  RETVAL


# The get method really should return the value rather than
# status - return undef on error. Also we can determine whether
# we have an int or a column name using SvIOK

# Always return stringified form or we use getstring and getnum
# to return string or number

# CHANGE IN API

char *
QueryResult::get( row, col )
  int row
  SV * col
 PREINIT:
  int status;
  /* Have no idea whether I need to free this memory */
  char * cresult = new char[128]; /* hope this is large enough */
 CODE:
  if (SvIOK(col)) {
    /* an integer */
    int colnum = SvIV( col );
    status = THIS->get(row, colnum, *cresult);     
  } else {
    /* A string */
    char * colname = (char *)SvPV_nolen( col );
    status = THIS->get(row, colname, cresult);
  }
  RETVAL = cresult;
 OUTPUT:
  RETVAL


int
QueryResult::numRows()

int
QueryResult::numCols()

int
QueryResult::colIndex( name )
  const char * name

# Push each column name onto the stack

void
QueryResult::colNames()
 PREINIT:
  int i;
  int len;
  char ** names;
 PPCODE:
  names = THIS->colNames();
  for (i = 0; i < THIS->numCols(); i++) {
    len = strlen( *names );
    XPUSHs(sv_2mortal(newSVpv( *names++, len)));
  }



void
QueryResult::DESTROY()



( run in 0.573 second using v1.01-cache-2.11-cpan-71847e10f99 )