Named std::pair members

Hi all.

I recently stumbled over a discussion that asserted that code using
std::pair<string, int> instead of, say,  struct city_t { string name;
int pcode; };  is hard to read as every time we access the pair we just
work with first and second and the user does not immediately see what
first and second should be.

What do you think of the following solution where std::pair is extended
via a preprocessor macro to contain two arbitrarily named member
references in addition to first and second ... ?

br,
Martin

[code]
#include <map>
#include <string>

#define NAMED_PAIR_TYPE(TNAME, NAMED_FIRST, NAMED_SECOND)  \
template<typename T1, typename T2>                         \
struct TNAME : public std::pair<T1, T2>                    \
{                                                          \
	TNAME()                                                  \
	: pair()                                                 \
	, NAMED_FIRST(first)                                     \
	, NAMED_SECOND(second)                                   \
	{                                                        \
	}                                                        \
	                                                         \
	TNAME(T1 const& val1, T2 const& val2)                    \
	: pair(val1, val2)                                       \
	, NAMED_FIRST(first)                                     \
	, NAMED_SECOND(second)                                   \
	{                                                        \
	}                                                        \
	                                                         \
	template<typename OTHER1, typename OTHER2>               \
	TNAME(pair<OTHER1, OTHER2> const& r)                     \
	: pair(r)                                                \
	, NAMED_FIRST(first)                                     \
	, NAMED_SECOND(second)                                   \
	{                                                        \
	}                                                        \
	                                                         \
	/* first, second aliases:*/                              \
	T1 & NAMED_FIRST;                                        \
	T2 & NAMED_SECOND;                                       \
}                                                          \
/*;*/

NAMED_PAIR_TYPE(named_city_t, name, pcode);
typedef named_city_t<std::string, unsigned int>  city_t;
typedef std::map<city_t::first_type, city_t::second_type>  city_collection;

city_t get_city(std::string const& name)
{
	city_collection dummy;

	if(dummy.find(name) != dummy.end())
		return *dummy.find(name);
	else
		throw std::exception();
}	

int main(int argc, char* argv[])
{

	city_t a;
	city_t b("Foo", 12345);
	city_t c(b);
	a.name;
	a.pcode;

	city_t x = get_city("?");

	return 0;
}
[/code]

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Martin
10/21/2008 10:31:34 PM
comp.lang.c++.moderated 10705 articles. 11 followers. allnor (8507) is leader. Post Follow

9 Replies
697 Views

Similar Articles

[PageSpeed] 43
On Oct 22, 5:31 am, "Martin T." <0xCDCDC...@gmx.at> wrote:

> I recently stumbled over a discussion that asserted that code using
> std::pair<string, int> instead of, say,  struct city_t { string name;
> int pcode; };  is hard to read as every time we access the pair we just
> work with first and second and the user does not immediately see what
> first and second should be.

Makes perfect sense. town->name tells me more than town->first.

> What do you think of the following solution where std::pair is extended
> via a preprocessor macro to contain two arbitrarily named member
> references in addition to first and second ... ?

> #define NAMED_PAIR_TYPE(TNAME, NAMED_FIRST, NAMED_SECOND)  \
> template<typename T1, typename T2>                         \
> struct TNAME : public std::pair<T1, T2>                    \
> {                                                          \
>         TNAME()                                                  \
>         : pair()                                                 \
>         , NAMED_FIRST(first)                                     \
>         , NAMED_SECOND(second)                                   \
>         {                                                        \
>         }                                                        \
>                                                                  \
>         TNAME(T1 const& val1, T2 const& val2)                    \
>         : pair(val1, val2)                                       \
>         , NAMED_FIRST(first)                                     \
>         , NAMED_SECOND(second)                                   \
>         {                                                        \
>         }                                                        \
>                                                                  \
>         template<typename OTHER1, typename OTHER2>               \
>         TNAME(pair<OTHER1, OTHER2> const& r)                     \
>         : pair(r)                                                \
>         , NAMED_FIRST(first)                                     \
>         , NAMED_SECOND(second)                                   \
>         {                                                        \
>         }                                                        \
>                                                                  \
>         /* first, second aliases:*/                              \
>         T1 & NAMED_FIRST;                                        \
>         T2 & NAMED_SECOND;                                       \}                                                          \
>
> /*;*/
>
> NAMED_PAIR_TYPE(named_city_t, name, pcode);
> typedef named_city_t<std::string, unsigned int>  city_t;
> typedef std::map<city_t::first_type, city_t::second_type>  city_collection;

[]

It looks wasteful because you add two data members (references) just
to name the same thing differently.

I would rather add a couple of (inline) accessor functions:

     typedef std::pair<std::string, unsigned int>  city_t;
     inline std::string& get_name(city_t& c) { return c.first; }
     inline unsigned int& get_pcode(city_t& c) { return c.second; }

and than:

     citi_t city;
     std::string& name = get_name(city);

-- 
Max


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Maxim
10/22/2008 9:52:54 PM
Martin T. ha scritto:
> Hi all.
> 
> I recently stumbled over a discussion that asserted that code using
> std::pair<string, int> instead of, say,  struct city_t { string name;
> int pcode; };  is hard to read as every time we access the pair we just
> work with first and second and the user does not immediately see what
> first and second should be.
> 
> What do you think of the following solution where std::pair is extended
> via a preprocessor macro to contain two arbitrarily named member
> references in addition to first and second ... ?

It's quite bad, IMHO. There are several drawbacks with this approach:

1) although the C++ standard says that references might not require
storage, in most implementation reference members increase the size of a
class by the size of a pointer. In you case you have to multiply by two
  (that is 8 bytes on a lot of platforms). Frankly 8 bytes per element is
*a lot* for a simple readability improvement.

2) in case none of the two member types is const, pair<> is assignable,
but your type is not, because references forbids the declaration of the
implicit assignment operator (see 12.8/12). In the non-const/non-const
case (and only that case) you should provide an explicit assignment
operator.

3) this use of references can be used to circumvent const-correctness:

   NAMED_PAIR_TYPE(named_city_t, name, pcode);
   typedef named_city_t<std::string, unsigned int>  city_t;
   const city_t city("Segrate", 20090);
   city.name = "Vimodrone"; // Ops! Modifying a const object!

> 
> <snip>
> 
> city_t get_city(std::string const& name)
> {
>     city_collection dummy;
> 
>     if(dummy.find(name) != dummy.end())
>         return *dummy.find(name);

Of course, you realize that dummy is always empty with this code...

This is very inefficient, for two reasons:

1) You should cache the result of the first call:

   city_collection::iterator it = dummy.find(name);
   if (it != dummy.end())
     return *it;

2) the return statement makes a copy of returned object

Moreover, while the map has immutable keys (you can't change the "first"
in elements of maps, because it has an added "const"), the returned
value has a non-const "city" member. This can be misleading.

A better idiom, in my opinion, is the following:

typedef std::map<std::string, int>  city_collection;
typedef city_collection::value_type city_t;

// you can wrap these in a macro if you want:
inline const std::string& city(const city_t& p) { return p.first; }
inline int& pcode(city_t& p)                    { return p.second; }
inline const int& pcode(const city_t& p)        { return p.second; }

int main(int argc, char* argv[])
{
     city_t b("Milano", 20100);
     city_t c(b);

     name(b);
     pcode(b);

     return 0;
}

Just my opinion,

Ganesh

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Alberto
10/22/2008 10:18:05 PM
Alberto Ganesh Barbati wrote:
> Martin T. ha scritto:
>> Hi all.
>>
>> I recently stumbled over a discussion that asserted that code using
>> std::pair<string, int> instead of, say,  struct city_t { string name;
>> int pcode; };  is hard to read as every time we access the pair we just
>> work with first and second and the user does not immediately see what
>> first and second should be.
>>
>> What do you think of the following solution where std::pair is extended
>> via a preprocessor macro to contain two arbitrarily named member
>> references in addition to first and second ... ?
> 
> It's quite bad, IMHO. There are several drawbacks with this approach:
> 
> 1) although the C++ standard says that references might not require
> storage, in most implementation reference members increase the size of a
> class by the size of a pointer. In you case you have to multiply by two
>   (that is 8 bytes on a lot of platforms). Frankly 8 bytes per element is
> *a lot* for a simple readability improvement.
> 

I agree with you and Maxim that the reference approach isn't that good.
The one using accessor functions seems better.

> 2) in case none of the two member types is const, pair<> is assignable,
> but your type is not, because references forbids the declaration of the
> implicit assignment operator (see 12.8/12). In the non-const/non-const
> case (and only that case) you should provide an explicit assignment
> operator.
> 

OK. Something new for me. Never stumbled over this up to now ...
probably because adding reference members is not exactly a day-to-day
thing :)

> 3) this use of references can be used to circumvent const-correctness:
> 
>    NAMED_PAIR_TYPE(named_city_t, name, pcode);
>    typedef named_city_t<std::string, unsigned int>  city_t;
>    const city_t city("Segrate", 20090);
>    city.name = "Vimodrone"; // Ops! Modifying a const object!
> 

Ouch!! Didn't know that. With pointers it's kinda more obvious.

>> <snip>
>>
>> city_t get_city(std::string const& name)
>> {
>>     city_collection dummy;
>>
>>     if(dummy.find(name) != dummy.end())
>>         return *dummy.find(name);
> 
> Of course, you realize that dummy is always empty with this code...

Just was to test that it compiles.

> 
> A better idiom, in my opinion, is the following:
> 
> typedef std::map<std::string, int>  city_collection;
> typedef city_collection::value_type city_t;
> 
> // you can wrap these in a macro if you want:
> inline const std::string& city(const city_t& p) { return p.first; }
> inline int& pcode(city_t& p)                    { return p.second; }
> inline const int& pcode(const city_t& p)        { return p.second; }
> 

Hmmm ... Both you and Maxim used the free function approach for access.
Personally I much prefer the member-function approach as that can IMHO
help greatly with auto completion / "Intellisense" features.
And it's basically equivalent, or is it?

Here's a modified version:
[code]
#define NAMED_PAIR_TYPE(TNAME, NAMED_FIRST, NAMED_SECOND)  \
template<typename T1, typename T2>                         \
struct TNAME : public std::pair<T1, T2>                    \
{                                                          \
	TNAME() : pair() {}                                      \
	                                                         \
	TNAME(T1 const& val1, T2 const& val2)                    \
	: pair(val1, val2)                                       \
	{ }                                                      \
	                                                         \
	template<typename OTHER1, typename OTHER2>               \
	TNAME(pair<OTHER1, OTHER2> const& r)                     \
	: pair(r)                                                \
	{ }                                                      \
	                                                         \
	/* first, second aliases:*/                              \
	inline T1 const& NAMED_FIRST() const {return first;}     \
	inline T2 const& NAMED_SECOND() const {return second;}   \
	inline T1 & NAMED_FIRST() {return first;}                \
	inline T2 & NAMED_SECOND() {return second;}              \
}                                                          \
/*;*/
[/code]
cheers,
Martin


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Martin
10/23/2008 6:48:05 AM
On 22 oct, 06:31, "Martin T." <0xCDCDC...@gmx.at> wrote:
> Hi all.
>
> I recently stumbled over a discussion that asserted that code using
> std::pair<string, int> instead of, say,  struct city_t { string name;
> int pcode; };  is hard to read as every time we access the pair we just
> work with first and second and the user does not immediately see what
> first and second should be.
>
> What do you think of the following solution where std::pair is extended
> via a preprocessor macro to contain two arbitrarily named member
> references in addition to first and second ... ?

I think you should look into Boost.Fusion.


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Mathias
10/24/2008 4:31:37 PM
On Oct 23, 1:48 pm, "Martin T." <0xCDCDC...@gmx.at> wrote:
> Alberto Ganesh Barbati wrote:
> > Martin T. ha scritto:
> >> Hi all.
>
> >> I recently stumbled over a discussion that asserted that code using
> >> std::pair<string, int> instead of, say,  struct city_t { string name;
> >> int pcode; };  is hard to read as every time we access the pair we just
> >> work with first and second and the user does not immediately see what
> >> first and second should be.

[]

> Hmmm ... Both you and Maxim used the free function approach for access.
> Personally I much prefer the member-function approach as that can IMHO
> help greatly with auto completion / "Intellisense" features.
> And it's basically equivalent, or is it?
>
> Here's a modified version:
> [code]
> #define NAMED_PAIR_TYPE(TNAME, NAMED_FIRST, NAMED_SECOND)  \
> template<typename T1, typename T2>                         \
> struct TNAME : public std::pair<T1, T2>                    \
> {                                                          \
>         TNAME() : pair() {}                                      \
>                                                                  \
>         TNAME(T1 const& val1, T2 const& val2)                    \
>         : pair(val1, val2)                                       \
>         { }                                                      \
>                                                                  \
>         template<typename OTHER1, typename OTHER2>               \
>         TNAME(pair<OTHER1, OTHER2> const& r)                     \
>         : pair(r)                                                \
>         { }                                                      \
>                                                                  \
>         /* first, second aliases:*/                              \
>         inline T1 const& NAMED_FIRST() const {return first;}     \
>         inline T2 const& NAMED_SECOND() const {return second;}   \
>         inline T1 & NAMED_FIRST() {return first;}                \
>         inline T2 & NAMED_SECOND() {return second;}              \}                                                          \
>
> /*;*/
> [/code]

At this point it seems to be much simpler just to declare:

     struct city_t { string name; int pcode; };

as you mentioned in your original post and dispense with unnecessary
macro awkwardness.

Is there a reason why you would still like to use std::pair<>?

-- 
Max


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Maxim
10/24/2008 4:31:45 PM
I have seen people doing this:

#include "boost/tuple/tuple.hpp"
#include <string>

int main(int argc, char* argv[])
{
   enum { name, pcode };
   boost::tuples::tuple<std::string, int> np;

   np.get<name>() = "Olso";
   np.get<pcode>() = 12345;

   int n = np.get<pcode>();
   std::string s = np.get<name>();

   return 0;
}

Regards,
eca

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
eca
10/24/2008 4:31:48 PM
Maxim Yegorushkin wrote:
> On Oct 23, 1:48 pm, "Martin T." <0xCDCDC...@gmx.at> wrote:
>> Alberto Ganesh Barbati wrote:
>>> Martin T. ha scritto:
>>>> Hi all.
>>>> I recently stumbled over a discussion that asserted that code using
>>>> std::pair<string, int> instead of, say,  struct city_t { string name;
>>>> int pcode; };  is hard to read as every time we access the pair we just
>>>> work with first and second and the user does not immediately see what
>>>> first and second should be.
> 
> []
> 
>> ...
> 
> At this point it seems to be much simpler just to declare:
> 
>      struct city_t { string name; int pcode; };
> 
> as you mentioned in your original post and dispense with unnecessary
> macro awkwardness.
> 
> Is there a reason why you would still like to use std::pair<>?
> 

Some algorithm or container might work with std::pair so I need 
something "compatible" with it.

br,
Martin

-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Martin
10/25/2008 2:33:23 PM
On 10/21/08 23:31, Martin T. wrote:
> I recently stumbled over a discussion that asserted that code using
> std::pair<string, int> instead of, say,  struct city_t { string name;
> int pcode; };  is hard to read as every time we access the pair we just
> work with first and second and the user does not immediately see what
> first and second should be.
>
> What do you think of the following solution where std::pair is extended
> via a preprocessor macro to contain two arbitrarily named member
> references in addition to first and second ... ?
[snip]

Boost fusion's vector:

http://www.boost.org/doc/libs/1_36_0/libs/fusion/doc/html/fusion/container/v
ector.html

does something similar for any number of fields up to some boost
maximum (or at least it did last time I looked at the implementation
several years ago) ; however, the preprocessor generated field names
are just m0,m1,...mn.  Of course those names are even harder to read
than first and second.  However, I'm guessing that the preproccessor
magic that fusion uses to generate the vector could be adapted to
generate more readable names similar to your proposal.


HTH,

Larry



-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
Larry
10/27/2008 9:19:37 AM
On Oct 27, 4:19 pm, Larry Evans <cppljev...@suddenlink.net> wrote:
> On 10/21/08 23:31, Martin T. wrote:> I recently stumbled over a discussion
that asserted that code using
> > std::pair<string, int> instead of, say,  struct city_t { string name;
> > int pcode; };  is hard to read as every time we access the pair we just
> > work with first and second and the user does not immediately see what
> > first and second should be.
>
> > What do you think of the following solution where std::pair is extended
> > via a preprocessor macro to contain two arbitrarily named member
> > references in addition to first and second ... ?
>
> [snip]
>
> Boost fusion's vector:
>
> http://www.boost.org/doc/libs/1_36_0/libs/fusion/doc/html/fusion/cont...
> ector.html
>
> does something similar for any number of fields up to some boost
> maximum (or at least it did last time I looked at the implementation
> several years ago) ; however, the preprocessor generated field names
> are just m0,m1,...mn.  Of course those names are even harder to read
> than first and second.  However, I'm guessing that the preproccessor
> magic that fusion uses to generate the vector could be adapted to
> generate more readable names similar to your proposal.
>

Fusion provides a macro to adapt the struct of your choice (with
whatever member names you like) as a fusion sequence.

--
gpd


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
gpderetta
10/28/2008 4:23:35 PM
Reply:
Similar Artilces:

RDoc : hyperlinked names of classes
Hi I would like to hyperlink the name of a class in RDoc markup while adding an 's' at the end of the name. How can I tell Rdoc to stop interpreting the name just before that 's' (whithoud having an extra space or other separator before the 's' in the resulting HTML page) ? Example: # #Things are used to... class Thing .... end => RDoc does not hyperlink the substring "Thing" because it only looks for a class named 'Things' not 'Thing' Thanks for your help. ...

Whats the name of this game?
I apologize if this is off topic. I'm trying to remember a game I have not played in 10 years on the Apple II. Its a game where you travel to different planets and iirc, you assess if you can take over those planets based on the type of system, population etc. Can anyone remember what its called? steve lim <supersteve3d@gmail.com> wrote: > Its a game where you travel to different planets and iirc, you assess > if you can take over those planets based on the type of system, > population etc. Might be Broderbund's Galactic Empire (part of the Galactic Saga...

Average all-pair paths on a graph
Hi All, I know how to calculate the all-pair shortest paths matrix on an undirected graph. I was wondering how I could extend this to calculate the all-pair average path, or if not a simple extension an efficient algorithm to compute this. Any help much appreciated, Adam ...

User Name question
Hi, When I start Palm on my PC, it is now asking, Select a User but none is shown in the window or Profiles. Added what I know to be my User Name via the New button and then selected it in Profiles but just goes back into the same loop telling me that You Must Enter At Least One User Name. Could Palm just be corrupt? Cheers. Barney. ...

I know your name.
I know where you live. I'll be sending a gift. ...

Re: dealing with library name? #16 1563027
Hi, I Subscribe to SAS-L in digest form. I'm not sure that I have seen every posting on this issue, but I did notice one thing in your code. where translate.cusip6=repo1.cusip6 177 and repo1.cusip6=&in_ds..cusip6 at Line 177, &in_ds..cusip6 is going to resolve to celia.bad1.cusip6 &in_ds resolves to celia.bad1, one of the periods is "eaten" by SAS to end the macro variable name, and the remaining period places a second period into the string. I don't think SAS will be able to figure out what to do with two dots in the string. (celia.bad1.cusip6) ...

formatting array/cell/matrix with column names
Hi all, I have input vector dataset, say 'x'. x=[value1 value2 value3] By some optimization over some function and i have estimated values, 'xhat'. xhat=[val1 val2 val3] Of same length, I want to format the output as Observed Fitted value1 val1 value2 val2 value3 val3 I can achieve this by [x' xhat'], but it does not have column names. I want it to be formated with names. How should I do that? Sorry if that's a bit basic. Casper ...

question: std:string and float values??
I am starting to use templates and have managed to figure out how to use std::string, std::map and make_pair successfully so far (Yeah I know - not much of a big step but I'm getting there) Previously I was using something like: char *buffer[50]; double value = 10.5; sprintf(buffer, "text %.2f text", value); How should I do this using an std:string in the place of the buffer variable? Thanks in advance Sean Hannan Woodster wrote: > I am starting to use templates and have managed to figure out how to use > std::string, std::map and make_pair successfully so far (Y...

instance from class name?
Hello, I am new to this list (and language) but I didn't find my answer from =20= the documentation available. I simply would like to do something like: myObject =3D class.fromName("a_class_name").new I can do this in Java and Objective-C but didn't find how in Ruby. =20 The idea is to have some configuration files for an activity which =20 contain a class name to instantiate depending on the activity. Many thanks (and sorry if this is an obvious question), -- Alexander Lamb Service d'Informatique M=E9dicale H=F4pitaux Universitaires de Gen=E8ve Alexander.J.Lamb@sim...

Name Extraction
Hi Friends i have following string jayabharathy@angleritech.com~Vs~kannan@angleritech.com the above string has 2 email ids in it.but i need only names of it. i want to extract only the names jayabharathy kannan how can i implemend that Kindly Let me Know -- Posted via http://www.ruby-forum.com/. Newb Newb escreveu: > Hi Friends > > i have following string > > jayabharathy@angleritech.com~Vs~kannan@angleritech.com > > the above string has 2 email ids in it.but i need only names of it. > > i want to extract only the names > > jayabharathy > > kan...

Re: SAS/ACCESS Libname: Reading Tables with Names Longer than 32 #6
Does this LIBNAME option have any effect on your problem? preserve_tab_names=yes On 8/27/09, Paul Miller <pjmiller_57@yahoo.com> wrote: > Hi Dan, and Art, and others, > > Yes, the problem is that the SQL Server table names are too long. My libname > > libname sqllib oledb provider=SQLOLEDB datasource='xxxx' user=xxxx password=xxxx properties=("Initial Catalog"=xxxx) > prompt=yes schema=dbo dbmax_text=32767; > > only allows me to read tables with names up to 32 characters long. > > The problem is that I'm routinely receiving SQl Server...

Prepend name to function names?
I was asked whether it is possible to prepend a name (using macro substitution) to all function names in a file/program. For example, the functions f1(), f2(), f3() should get aa_ prepended to their names? I.e., f1(), f2(), f3() should be changed to aa_f1(), aa_f2(), aa_f3() using some macro substitution. I came up with the following: **************************************************** #include <stdio.h> #define PREPEND aa_ #define MAKE_FUNC_NAME(prepend, func_name) prepend ## func_name void MAKE_FUNC_NAME(PREPEND, f1)(void) { printf("here..\n"); } **********************...

Re: A record of domain name must be name server ? #2
--001a11c2cbd8184cd60502cd4d43 Content-Type: text/plain; charset=UTF-8 In reference to the question of using a CNAME or A record for " www.example.com", it seems to me that the best solution, if we could ever get there, would be to create a new record type that means "redirect an A or AAAA lookup to this other name". Like this: example.com. IN SOA .... example.com. IN ANAME my.webhosting.com. www.example.com. IN CNAME my.webhosting.com. I use "ANAME" to mean "like a CNAME, but only for A and AAAA lookups", with no restrictions o...

S-Function Name
I wrote C file for S Function and when I try to compile the C-files with mex command, the resulting S-Function name takes some default name. I tried to change the resulting S- Function name with '-output' option but no luck at all. It always goes back to the default name. Does anyone know how to control the resulting S-Function name ? p.s. I am using Windows XP machine Thanks in advanced Are you starting with the template file: sfuntmpl_basic.c ? If your c-mex sfunction is called MySFunction.c And within the file you have the line #define S_FUNCTION_NAME MySFunctio...

Handling multiple portType definitions with the same method name with built-in SOAP
I am trying to communicate with a WSDL that defines to portTypes: - <portType name="General"> - <portType name="Session"> And their exists 2 operations with the same name but in 2 different porttypes (the general "GetList" returns a default list of items, the session "GetList" requires a session ID to be passed in the header and returns a list based on the session ID): - <operation name="GetList"> <soap:operation soapAction="urn:XXX-General#GetList" style="rpc" /> - <input message="tns:Ge...

Name of the game wanted
Hi, I am looking for the name of an old BBC model B game. Here is what I remember about it: It is 2D block moving game. It was written mostly in BBC Basic with some assembler parts. At the start of the game the screen was randomly filled with the bricks and the several small creatures (small squares with a cat face or something like this) These creatures start moving toward you (small man) Each of your turns is followed by one turn from each cat face. Your goal is to block all the creaturres by locking them (building walls) with the bricks. You can push bricks in front of you...

FAQ 5.6 How do I make a temporary file name? 326368
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 5.6: How do I make a temporary file name? If you don't need to know the name of the file, you can use "open()" with "undef" in place of the file name. The "open()" function creates an anonymous temporary file. open my $tmp...

Naming convention
Hi all, I'm new to RB, coming fromVB/Access world. I'm currently going through the tuturial and all seems to make sense. As you can imagine I'm comparing things to VB. In VB I have gotten use to a naming convention, you know - prefixing objects/variables with a three letter code which references the variable or control. Is there a document which recommends a suggested naming convention for RB variables, controls etc. Thanks in advance. Steven Taylor Melbourne, Australia. Like VB you can name them whatever you want to. "Steven Taylor" <satayl...

Combining TAO Name Service with Implementation Repository for Persistent Object References
Hi, I am setting up a TAO-based CORBA application, and I would like my object references to be persistent, i.e. I would like my client to transparently continue using the object references when my server is restarted in between. I made it to work with persistent object references, which has the drawback that I have to make sure that my server ORB always start at the same port, which is not practicable for the application I have, since it also means fixing a port number for every server instance running(I will have many servers running in a complex environment). Then I read about the...

Name of Calling Feature
I have been aware of a custom calling feature that allows you to call a number and be intercepted with a prompt to enter a PIN number before the call is allowed to ring through. What is the name of this customer calling service? Regards, Fred ...

import variable names from delimited files
Hi- I have a bunch of dollar delimited files for conversion to SAS datasets. I've written a small macro code using Proc import with guessing rows=1000 (needed as some colums have a lot of numerical data with few character values). It works fine, only issue is that occasionaly a couple of files are empty (i.e they have column headers but no data values). In such a case, I still want empty SAS datasets to be created giving the variable names. However if there are no datavalues, SAS gives an error such as this: "Unable to sample external file, no data in first 5 records." Thanks ...

Class Name
Is there a way during compilation or preprocessor phase to get the class the compiler is currently in? [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] Michael D. Borghardt wrote: > Is there a way during compilation or preprocessor phase to get the class > the compiler is currently in? Adding #warning Your Text message to your source code prints arbitrary messages to the console/compiler window at compile time. You could add this to all your classes to get the desired result. But I don't know i...

PIX name change
I have a line in my PIX 506e configuration that reads: name 192.168.0.0 LSSphiliTunnel 192.168.0.0 refers to our INTERNAL IP range. LSIphiliTunnel refers to an office that is no longer needed. I was not the person who originally programmed the PIX so I am not sure why they choose to name our internal IP range using the name of a branch office. But anyway, I wanted to change the name to better reflect it's description....like: name 192.168.0.0 LSS_Internal_IP_Range Now since I renamed the host associated with that IP range, I just need to go through the config and change all referen...

Naming Names
Naming Names -------- The following is a brief list of observations concerning ad hominem remarks or the naming of names in scientific contexts. Arguments can never be of more general significance than names named. For example, addressing critical arguments to ideas or thoughts, makes the arguments more general than if addressed to an individual whereas arguments addressed to an individual are of more specific and less general significance than those addressed to ideas and thoughts of an individual. Addressi...

name that game! #2 1225010
Hi everyone, wonder if any of you can identify this ZX Speccy game I used to play years ago. You had to guide some kind of emu or ostrich, maybe wearing a space suit, I can't remember, over the surface of a planet (maybe the moon?), picking up things. Health level was shown by a chicken or some kind of cooked bird at the bottom of the screen, as you got hurt it would gradually become a carcass with bones sticking out the top. At some point you could go underground and there was some sort of rail system with carts that move backwards and forwards. Also I seem to remember having to h...