1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
#pike __REAL_VERSION__ 
 
//! Generic base classes for the Sql interfaces. 
 
//! Wrapper to handle conversion of zero to NULL in 
//! @[Connection()->handle_extraargs()]. 
//! 
//! @seealso 
//!   @[zero] 
protected class ZeroWrapper 
{ 
  //! @returns 
  //!   Returns the following: 
  //!   @string 
  //!     @value "NULL" 
  //!       If @[fmt] is @expr{'s'@}. 
  //!     @value "ZeroWrapper()" 
  //!       If @[fmt] is @expr{'O'@}. 
  //!   @endstring 
  //!   Otherwise it formats a @expr{0@} (zero). 
  protected string _sprintf(int fmt, mapping(string:mixed) params) 
  { 
    if (fmt == 's') return "NULL"; 
    if (fmt == 'O') return "ZeroWrapper()"; 
    return sprintf(sprintf("%%*%c", fmt), params, 0); 
  } 
} 
 
//! Instance of @[ZeroWrapper] used by @[Connection()->handle_extraargs()]. 
ZeroWrapper zero = ZeroWrapper(); 
 
protected class NullArg 
{ 
  protected string _sprintf (int fmt) 
  { 
    return fmt == 'O' ? "NullArg()" : "NULL"; 
  } 
} 
NullArg null_arg = NullArg();