rename stuff in the C++ API for stream -> source

This commit is contained in:
John Cupitt 2019-12-30 17:49:41 +00:00
parent 3847f71c54
commit 95444d0849
10 changed files with 138 additions and 120 deletions

View File

@ -11,7 +11,7 @@ lib_LTLIBRARIES = libvips-cpp.la
libvips_cpp_la_SOURCES = \
VImage.cpp \
VInterpolate.cpp \
VStream.cpp \
VConnection.cpp \
VError.cpp
libvips_cpp_la_LDFLAGS = \

View File

@ -1,4 +1,4 @@
/* Object part of the VStreamI and VStreamO class
/* Object part of the VSource and VTarget class
*/
/*
@ -44,47 +44,47 @@
VIPS_NAMESPACE_START
VStreamI
VStreamI::new_from_descriptor( int descriptor )
VSource
VSource::new_from_descriptor( int descriptor )
{
VipsSource *input;
if( !(input = vips_source_new_from_descriptor( descriptor )) )
throw VError();
VStreamI out( input );
VSource out( input );
return( out );
}
VStreamI
VStreamI::new_from_file( const char *filename )
VSource
VSource::new_from_file( const char *filename )
{
VipsSource *input;
if( !(input = vips_source_new_from_file( filename )) )
throw VError();
VStreamI out( input );
VSource out( input );
return( out );
}
VStreamI
VStreamI::new_from_blob( VipsBlob *blob )
VSource
VSource::new_from_blob( VipsBlob *blob )
{
VipsSource *input;
if( !(input = vips_source_new_from_blob( blob )) )
throw VError();
VStreamI out( input );
VSource out( input );
return( out );
}
VStreamI
VStreamI::new_from_memory( const void *data,
VSource
VSource::new_from_memory( const void *data,
size_t size )
{
VipsSource *input;
@ -92,84 +92,84 @@ VStreamI::new_from_memory( const void *data,
if( !(input = vips_source_new_from_memory( data, size )) )
throw VError();
VStreamI out( input );
VSource out( input );
return( out );
}
VStreamI
VStreamI::new_from_options( const char *options )
VSource
VSource::new_from_options( const char *options )
{
VipsSource *input;
if( !(input = vips_source_new_from_options( options )) )
throw VError();
VStreamI out( input );
VSource out( input );
return( out );
}
VOption *
VOption::set( const char *name, const VStreamI value )
VOption::set( const char *name, const VSource value )
{
Pair *pair = new Pair( name );
pair->input = true;
g_value_init( &pair->value, VIPS_TYPE_SOURCE );
g_value_set_object( &pair->value, value.get_stream() );
g_value_set_object( &pair->value, value.get_source() );
options.push_back( pair );
return( this );
}
VStreamO
VStreamO::new_to_descriptor( int descriptor )
VTarget
VTarget::new_to_descriptor( int descriptor )
{
VipsTarget *output;
if( !(output = vips_target_new_to_descriptor( descriptor )) )
throw VError();
VStreamO out( output );
VTarget out( output );
return( out );
}
VStreamO
VStreamO::new_to_file( const char *filename )
VTarget
VTarget::new_to_file( const char *filename )
{
VipsTarget *output;
if( !(output = vips_target_new_to_file( filename )) )
throw VError();
VStreamO out( output );
VTarget out( output );
return( out );
}
VStreamO
VStreamO::new_to_memory()
VTarget
VTarget::new_to_memory()
{
VipsTarget *output;
if( !(output = vips_target_new_to_memory()) )
throw VError();
VStreamO out( output );
VTarget out( output );
return( out );
}
VOption *
VOption::set( const char *name, const VStreamO value )
VOption::set( const char *name, const VTarget value )
{
Pair *pair = new Pair( name );
pair->input = true;
g_value_init( &pair->value, VIPS_TYPE_TARGET );
g_value_set_object( &pair->value, value.get_stream() );
g_value_set_object( &pair->value, value.get_target() );
options.push_back( pair );
return( this );

View File

@ -597,14 +597,14 @@ VImage::new_from_buffer( const std::string &buf, const char *option_string,
}
VImage
VImage::new_from_source( VStreamI source, const char *option_string,
VImage::new_from_source( VSource source, const char *option_string,
VOption *options )
{
const char *operation_name;
VImage out;
if( !(operation_name = vips_foreign_find_load_source(
source.get_stream() )) ) {
source.get_source() )) ) {
delete options;
throw( VError() );
}
@ -703,7 +703,7 @@ VImage::write_to_buffer( const char *suffix, void **buf, size_t *size,
}
void
VImage::write_to_target( const char *suffix, VStreamO target,
VImage::write_to_target( const char *suffix, VTarget target,
VOption *options ) const
{
char filename[VIPS_PATH_MAX];

View File

@ -29,8 +29,8 @@ from pyvips import Introspect, Operation, GValue, Error, \
ffi, gobject_lib, type_map, type_from_name, nickname_find, type_name
# TODO Move to pyvips.GValue
stream_input_type = type_from_name('VipsStreami')
stream_output_type = type_from_name('VipsStreamo')
source_type = type_from_name('VipsSource')
target_type = type_from_name('VipsTarget')
# turn a GType into a C++ type
gtype_to_cpp = {
@ -41,8 +41,8 @@ gtype_to_cpp = {
GValue.refstr_type: 'char *',
GValue.gflags_type: 'int',
GValue.image_type: 'VImage',
stream_input_type: 'VStreamI',
stream_output_type: 'VStreamO',
source_type: 'VSource',
target_type: 'VTarget',
GValue.array_int_type: 'std::vector<int>',
GValue.array_double_type: 'std::vector<double>',
GValue.array_image_type: 'std::vector<VImage>',

View File

@ -2,7 +2,7 @@ pkginclude_HEADERS = \
VError8.h \
VImage8.h \
VInterpolate8.h \
VStream8.h \
VConnection8.h \
vips8 \
vips-operators.h

View File

@ -1,4 +1,4 @@
// VIPS stream input/output wrapper
// VIPS connection wrapper
/*
@ -27,64 +27,64 @@
*/
#ifndef VIPS_VSTREAM_H
#define VIPS_VSTREAM_H
#ifndef VIPS_VCONNECTION_H
#define VIPS_VCONNECTION_H
#include <vips/vips.h>
VIPS_NAMESPACE_START
class VStreamI : VObject
class VSource : VObject
{
public:
VStreamI( VipsSource *input, VSteal steal = STEAL ) :
VSource( VipsSource *input, VSteal steal = STEAL ) :
VObject( (VipsObject *) input, steal )
{
}
static
VStreamI new_from_descriptor( int descriptor );
VSource new_from_descriptor( int descriptor );
static
VStreamI new_from_file( const char *filename );
VSource new_from_file( const char *filename );
static
VStreamI new_from_blob( VipsBlob *blob );
VSource new_from_blob( VipsBlob *blob );
static
VStreamI new_from_memory( const void *data,
VSource new_from_memory( const void *data,
size_t size );
static
VStreamI new_from_options( const char *options );
VSource new_from_options( const char *options );
VipsSource *
get_stream() const
get_source() const
{
return( (VipsSource *) VObject::get_object() );
}
};
class VStreamO : VObject
class VTarget : VObject
{
public:
VStreamO( VipsTarget *output, VSteal steal = STEAL ) :
VTarget( VipsTarget *output, VSteal steal = STEAL ) :
VObject( (VipsObject *) output, steal )
{
}
static
VStreamO new_to_descriptor( int descriptor );
VTarget new_to_descriptor( int descriptor );
static
VStreamO new_to_file( const char *filename );
VTarget new_to_file( const char *filename );
static
VStreamO new_to_memory();
VTarget new_to_memory();
VipsTarget *
get_stream() const
get_target() const
{
return( (VipsTarget *) VObject::get_object() );
}
@ -93,4 +93,4 @@ public:
VIPS_NAMESPACE_END
#endif /*VIPS_VSTREAM_H*/
#endif /*VIPS_VCONNECTION_H*/

View File

@ -169,8 +169,8 @@ public:
class VIPS_CPLUSPLUS_API VImage;
class VIPS_CPLUSPLUS_API VInterpolate;
class VIPS_CPLUSPLUS_API VStreamI;
class VIPS_CPLUSPLUS_API VStreamO;
class VIPS_CPLUSPLUS_API VSource;
class VIPS_CPLUSPLUS_API VTarget;
class VIPS_CPLUSPLUS_API VOption;
class VOption
@ -224,8 +224,8 @@ public:
VOption *set( const char *name, const char *value );
VOption *set( const char *name, const VImage value );
VOption *set( const char *name, const VInterpolate value );
VOption *set( const char *name, const VStreamI value );
VOption *set( const char *name, const VStreamO value );
VOption *set( const char *name, const VSource value );
VOption *set( const char *name, const VTarget value );
VOption *set( const char *name, std::vector<VImage> value );
VOption *set( const char *name, std::vector<double> value );
VOption *set( const char *name, std::vector<int> value );
@ -514,7 +514,7 @@ public:
static VImage new_from_buffer( const std::string &buf,
const char *option_string, VOption *options = 0 );
static VImage new_from_source( VStreamI source,
static VImage new_from_source( VSource source,
const char *option_string, VOption *options = 0 );
static VImage new_matrix( int width, int height );
@ -569,7 +569,7 @@ public:
void write_to_buffer( const char *suffix, void **buf, size_t *size,
VOption *options = 0 ) const;
void write_to_target( const char *suffix, VStreamO target,
void write_to_target( const char *suffix, VTarget target,
VOption *options = 0 ) const;
void *

View File

@ -1,5 +1,5 @@
// headers for vips operations
// Fri 29 Nov 2019 02:46:41 PM CET
// Mon 30 Dec 17:45:50 GMT 2019
// this file is generated automatically, do not edit!
/**
@ -1038,12 +1038,12 @@ static VImage jpegload( const char *filename, VOption *options = 0 );
static VImage jpegload_buffer( VipsBlob *buffer, VOption *options = 0 );
/**
* Load image from jpeg stream.
* @param source Stream to load from.
* Load image from jpeg source.
* @param source Source to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage jpegload_stream( VStreamI source, VOption *options = 0 );
static VImage jpegload_source( VSource source, VOption *options = 0 );
/**
* Save image to jpeg file.
@ -1066,11 +1066,11 @@ VipsBlob *jpegsave_buffer( VOption *options = 0 ) const;
void jpegsave_mime( VOption *options = 0 ) const;
/**
* Save image to jpeg stream.
* @param target Stream to save to.
* Save image to jpeg target.
* @param target Target to save to.
* @param options Optional options.
*/
void jpegsave_stream( VStreamO target, VOption *options = 0 ) const;
void jpegsave_target( VTarget target, VOption *options = 0 ) const;
/**
* Label regions in an image.
@ -1507,6 +1507,13 @@ VImage phasecor( VImage in2, VOption *options = 0 ) const;
*/
static VImage pngload( const char *filename, VOption *options = 0 );
/**
* Load png base class.
* @param options Optional options.
* @return Output image.
*/
static VImage pngload_base( VOption *options = 0 );
/**
* Load png from buffer.
* @param buffer Buffer to load from.
@ -1516,12 +1523,12 @@ static VImage pngload( const char *filename, VOption *options = 0 );
static VImage pngload_buffer( VipsBlob *buffer, VOption *options = 0 );
/**
* Load png from stream.
* @param source Stream to load from.
* Load png from source.
* @param source Source to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage pngload_stream( VStreamI source, VOption *options = 0 );
static VImage pngload_source( VSource source, VOption *options = 0 );
/**
* Save image to png file.
@ -1538,11 +1545,11 @@ void pngsave( const char *filename, VOption *options = 0 ) const;
VipsBlob *pngsave_buffer( VOption *options = 0 ) const;
/**
* Save image to png stream.
* @param target Stream to save to.
* Save image to target as png.
* @param target Target to save to.
* @param options Optional options.
*/
void pngsave_stream( VStreamO target, VOption *options = 0 ) const;
void pngsave_target( VTarget target, VOption *options = 0 ) const;
/**
* Load ppm from file.
@ -1622,12 +1629,12 @@ static VImage radload( const char *filename, VOption *options = 0 );
static VImage radload_buffer( VipsBlob *buffer, VOption *options = 0 );
/**
* Load rad from stream.
* @param source Stream to load from.
* Load rad from source.
* @param source Source to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage radload_stream( VStreamI source, VOption *options = 0 );
static VImage radload_source( VSource source, VOption *options = 0 );
/**
* Save image to radiance file.
@ -1644,11 +1651,11 @@ void radsave( const char *filename, VOption *options = 0 ) const;
VipsBlob *radsave_buffer( VOption *options = 0 ) const;
/**
* Save image to radiance stream.
* @param target Stream to save to.
* Save image to radiance target.
* @param target Target to save to.
* @param options Optional options.
*/
void radsave_stream( VStreamO target, VOption *options = 0 ) const;
void radsave_target( VTarget target, VOption *options = 0 ) const;
/**
* Rank filter.
@ -1993,12 +2000,12 @@ static VImage svgload( const char *filename, VOption *options = 0 );
static VImage svgload_buffer( VipsBlob *buffer, VOption *options = 0 );
/**
* Load svg from stream.
* @param source Stream to load from.
* Load svg from source.
* @param source Source to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage svgload_stream( VStreamI source, VOption *options = 0 );
static VImage svgload_source( VSource source, VOption *options = 0 );
/**
* Find the index of the first non-zero pixel in tests.
@ -2050,13 +2057,13 @@ static VImage thumbnail_buffer( VipsBlob *buffer, int width, VOption *options =
VImage thumbnail_image( int width, VOption *options = 0 ) const;
/**
* Generate thumbnail from stream.
* @param source Stream to load from.
* Generate thumbnail from source.
* @param source Source to load from.
* @param width Size to this width.
* @param options Optional options.
* @return Output image.
*/
static VImage thumbnail_stream( VStreamI source, int width, VOption *options = 0 );
static VImage thumbnail_source( VSource source, int width, VOption *options = 0 );
/**
* Load tiff from file.
@ -2075,12 +2082,12 @@ static VImage tiffload( const char *filename, VOption *options = 0 );
static VImage tiffload_buffer( VipsBlob *buffer, VOption *options = 0 );
/**
* Load tiff from stream.
* @param source Stream to load from.
* Load tiff from source.
* @param source Source to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage tiffload_stream( VStreamI source, VOption *options = 0 );
static VImage tiffload_source( VSource source, VOption *options = 0 );
/**
* Save image to tiff file.
@ -2156,12 +2163,12 @@ static VImage webpload( const char *filename, VOption *options = 0 );
static VImage webpload_buffer( VipsBlob *buffer, VOption *options = 0 );
/**
* Load webp from stream.
* @param source Stream to load from.
* Load webp from source.
* @param source Source to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage webpload_stream( VStreamI source, VOption *options = 0 );
static VImage webpload_source( VSource source, VOption *options = 0 );
/**
* Save image to webp file.
@ -2178,11 +2185,11 @@ void webpsave( const char *filename, VOption *options = 0 ) const;
VipsBlob *webpsave_buffer( VOption *options = 0 ) const;
/**
* Save image to webp stream.
* @param target Stream to save to.
* Save image to webp target.
* @param target Target to save to.
* @param options Optional options.
*/
void webpsave_stream( VStreamO target, VOption *options = 0 ) const;
void webpsave_target( VTarget target, VOption *options = 0 ) const;
/**
* Make a worley noise image.

View File

@ -52,6 +52,6 @@
#include "VError8.h"
#include "VImage8.h"
#include "VInterpolate8.h"
#include "VStream8.h"
#include "VConnection8.h"
#endif /*VIPS_CPLUSPLUS*/

View File

@ -1,5 +1,5 @@
// bodies for vips operations
// Fri 29 Nov 2019 02:46:41 PM CET
// Mon 30 Dec 17:45:35 GMT 2019
// this file is generated automatically, do not edit!
VImage VImage::CMC2LCh( VOption *options ) const
@ -1628,11 +1628,11 @@ VImage VImage::jpegload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
VImage VImage::jpegload_stream( VStreamI source, VOption *options )
VImage VImage::jpegload_source( VSource source, VOption *options )
{
VImage out;
call( "jpegload_stream",
call( "jpegload_source",
(options ? options : VImage::option())->
set( "out", &out )->
set( "source", source ) );
@ -1667,9 +1667,9 @@ void VImage::jpegsave_mime( VOption *options ) const
set( "in", *this ) );
}
void VImage::jpegsave_stream( VStreamO target, VOption *options ) const
void VImage::jpegsave_target( VTarget target, VOption *options ) const
{
call( "jpegsave_stream",
call( "jpegsave_target",
(options ? options : VImage::option())->
set( "in", *this )->
set( "target", target ) );
@ -2307,6 +2307,17 @@ VImage VImage::pngload( const char *filename, VOption *options )
return( out );
}
VImage VImage::pngload_base( VOption *options )
{
VImage out;
call( "pngload_base",
(options ? options : VImage::option())->
set( "out", &out ) );
return( out );
}
VImage VImage::pngload_buffer( VipsBlob *buffer, VOption *options )
{
VImage out;
@ -2319,11 +2330,11 @@ VImage VImage::pngload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
VImage VImage::pngload_stream( VStreamI source, VOption *options )
VImage VImage::pngload_source( VSource source, VOption *options )
{
VImage out;
call( "pngload_stream",
call( "pngload_source",
(options ? options : VImage::option())->
set( "out", &out )->
set( "source", source ) );
@ -2351,9 +2362,9 @@ VipsBlob *VImage::pngsave_buffer( VOption *options ) const
return( buffer );
}
void VImage::pngsave_stream( VStreamO target, VOption *options ) const
void VImage::pngsave_target( VTarget target, VOption *options ) const
{
call( "pngsave_stream",
call( "pngsave_target",
(options ? options : VImage::option())->
set( "in", *this )->
set( "target", target ) );
@ -2478,11 +2489,11 @@ VImage VImage::radload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
VImage VImage::radload_stream( VStreamI source, VOption *options )
VImage VImage::radload_source( VSource source, VOption *options )
{
VImage out;
call( "radload_stream",
call( "radload_source",
(options ? options : VImage::option())->
set( "out", &out )->
set( "source", source ) );
@ -2510,9 +2521,9 @@ VipsBlob *VImage::radsave_buffer( VOption *options ) const
return( buffer );
}
void VImage::radsave_stream( VStreamO target, VOption *options ) const
void VImage::radsave_target( VTarget target, VOption *options ) const
{
call( "radsave_stream",
call( "radsave_target",
(options ? options : VImage::option())->
set( "in", *this )->
set( "target", target ) );
@ -3062,11 +3073,11 @@ VImage VImage::svgload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
VImage VImage::svgload_stream( VStreamI source, VOption *options )
VImage VImage::svgload_source( VSource source, VOption *options )
{
VImage out;
call( "svgload_stream",
call( "svgload_source",
(options ? options : VImage::option())->
set( "out", &out )->
set( "source", source ) );
@ -3144,11 +3155,11 @@ VImage VImage::thumbnail_image( int width, VOption *options ) const
return( out );
}
VImage VImage::thumbnail_stream( VStreamI source, int width, VOption *options )
VImage VImage::thumbnail_source( VSource source, int width, VOption *options )
{
VImage out;
call( "thumbnail_stream",
call( "thumbnail_source",
(options ? options : VImage::option())->
set( "out", &out )->
set( "source", source )->
@ -3181,11 +3192,11 @@ VImage VImage::tiffload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
VImage VImage::tiffload_stream( VStreamI source, VOption *options )
VImage VImage::tiffload_source( VSource source, VOption *options )
{
VImage out;
call( "tiffload_stream",
call( "tiffload_source",
(options ? options : VImage::option())->
set( "out", &out )->
set( "source", source ) );
@ -3304,11 +3315,11 @@ VImage VImage::webpload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
VImage VImage::webpload_stream( VStreamI source, VOption *options )
VImage VImage::webpload_source( VSource source, VOption *options )
{
VImage out;
call( "webpload_stream",
call( "webpload_source",
(options ? options : VImage::option())->
set( "out", &out )->
set( "source", source ) );
@ -3336,9 +3347,9 @@ VipsBlob *VImage::webpsave_buffer( VOption *options ) const
return( buffer );
}
void VImage::webpsave_stream( VStreamO target, VOption *options ) const
void VImage::webpsave_target( VTarget target, VOption *options ) const
{
call( "webpsave_stream",
call( "webpsave_target",
(options ? options : VImage::option())->
set( "in", *this )->
set( "target", target ) );