Commit cbf9c1dd0e857e406e833153f371219b1b65eaae
1 parent
a4521c67
Add GFitsTableStringCol.__setitem__ method for GFilename argument.
Showing
1 changed file
with
22 additions
and
1 deletions
pyext/GFitsTableStringCol.i
| 1 | /*************************************************************************** | 1 | /*************************************************************************** |
| 2 | * GFitsTableStringCol.i - FITS table string column class * | 2 | * GFitsTableStringCol.i - FITS table string column class * |
| 3 | * ----------------------------------------------------------------------- * | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2015 by Juergen Knoedlseder * | 4 | + * copyright (C) 2008-2016 by Juergen Knoedlseder * |
| 5 | * ----------------------------------------------------------------------- * | 5 | * ----------------------------------------------------------------------- * |
| 6 | * * | 6 | * * |
| 7 | * This program is free software: you can redistribute it and/or modify * | 7 | * This program is free software: you can redistribute it and/or modify * |
| @@ -26,6 +26,7 @@ | @@ -26,6 +26,7 @@ | ||
| 26 | %{ | 26 | %{ |
| 27 | /* Put headers and other declarations here that are needed for compilation */ | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | #include "GFitsTableStringCol.hpp" | 28 | #include "GFitsTableStringCol.hpp" |
| 29 | +#include "GFilename.hpp" | ||
| 29 | %} | 30 | %} |
| 30 | 31 | ||
| 31 | 32 | ||
| @@ -110,6 +111,26 @@ public: | @@ -110,6 +111,26 @@ public: | ||
| 110 | } | 111 | } |
| 111 | } | 112 | } |
| 112 | } | 113 | } |
| 114 | + void __setitem__(int GFitsTableColInx[], GFilename value) { | ||
| 115 | + if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->length()) { | ||
| 116 | + throw GException::out_of_range("__setitem__()", "Row index", | ||
| 117 | + GFitsTableColInx[1], self->length()); | ||
| 118 | + } | ||
| 119 | + if (GFitsTableColInx[0] == 1) { | ||
| 120 | + (*self)(GFitsTableColInx[1]) = std::string(value); | ||
| 121 | + } | ||
| 122 | + else { | ||
| 123 | + if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] < | ||
| 124 | + self->elements(GFitsTableColInx[1])) { | ||
| 125 | + (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = std::string(value); | ||
| 126 | + } | ||
| 127 | + else { | ||
| 128 | + throw GException::out_of_range("__setitem__()", "Column index", | ||
| 129 | + GFitsTableColInx[2], | ||
| 130 | + self->elements(GFitsTableColInx[1])); | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + } | ||
| 113 | GFitsTableStringCol copy() { | 134 | GFitsTableStringCol copy() { |
| 114 | return (*self); | 135 | return (*self); |
| 115 | } | 136 | } |