diff liboctave/util/lo-array-errwarn.cc @ 22327:d0562b3159c7

move more classes inside octave namespace * ov-complex.cc, quit.h, lo-array-errwarn.h, lo-array-errwarn.cc, lo-array-gripes.cc: Move classes inside octave namespace. * NEWS, file-editor-tab.cc, Cell.cc, __qp__.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, error.cc, error.h, errwarn.cc, errwarn.h, file-io.cc, gcd.cc, graphics.cc, graphics.in.h, gripes.cc, gripes.h, input.cc, interpreter.cc, interpreter.h, inv.cc, jit-typeinfo.cc, load-path.cc, ls-mat-ascii.cc, ls-mat5.cc, lsode.cc, mex.cc, oct-handle.h, oct-map.cc, oct-stream.cc, quad.cc, rand.cc, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, sub2ind.cc, toplev.cc, utils.cc, variables.cc, xdiv.cc, xpow.cc, __eigs__.cc, __init_gnuplot__.cc, ov-base-diag.cc, ov-base-mat.cc, ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-class.cc, ov-classdef.cc, ov-complex.h, ov-complex.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-float.cc, ov-float.h, ov-flt-complex.h, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-java.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov.cc, op-cs-cs.cc, op-fcs-fcs.cc, op-fs-fs.cc, op-int.h, op-s-s.cc, ops.h, oct-parse.in.yy, pt-assign.cc, pt-eval.cc, pt-idx.cc, pt.cc, Array-util.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MDiagArray2.cc, MSparse.cc, PermMatrix.cc, Range.cc, Sparse.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, quit.cc, quit.h, gepbalance.cc, Sparse-diag-op-defs.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, mx-inlines.cc, mx-op-defs.h, cmd-edit.cc, lo-array-errwarn.cc, lo-array-errwarn.h, lo-array-gripes.cc, lo-array-gripes.h, oct-binmap.h: Update to use namespace.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Aug 2016 03:41:42 -0400
parents 278fc29b69ca
children 4caa7b28d183
line wrap: on
line diff
--- a/liboctave/util/lo-array-errwarn.cc	Wed Aug 17 02:57:50 2016 -0400
+++ b/liboctave/util/lo-array-errwarn.cc	Wed Aug 17 03:41:42 2016 -0400
@@ -40,288 +40,291 @@
 
 static const char *warning_id_singular_matrix = "Octave:singular-matrix";
 
-void
-err_nan_to_logical_conversion (void)
-{
-  (*current_liboctave_error_handler)
-    ("invalid conversion from NaN to logical");
-}
-
-void
-err_nan_to_character_conversion (void)
+namespace octave
 {
-  (*current_liboctave_error_handler)
-    ("invalid conversion from NaN to character");
-}
+  void
+  err_nan_to_logical_conversion (void)
+  {
+    (*current_liboctave_error_handler)
+      ("invalid conversion from NaN to logical");
+  }
+
+  void
+  err_nan_to_character_conversion (void)
+  {
+    (*current_liboctave_error_handler)
+      ("invalid conversion from NaN to character");
+  }
+
+  void
+  err_nonconformant (const char *op,
+                     octave_idx_type op1_len, octave_idx_type op2_len)
+  {
+    const char *err_id = error_id_nonconformant_args;
 
-void
-err_nonconformant (const char *op,
-                   octave_idx_type op1_len, octave_idx_type op2_len)
-{
-  const char *err_id = error_id_nonconformant_args;
+    (*current_liboctave_error_with_id_handler)
+      (err_id, "%s: nonconformant arguments (op1 len: %d, op2 len: %d)",
+       op, op1_len, op2_len);
+  }
+
+  void
+  err_nonconformant (const char *op,
+                     octave_idx_type op1_nr, octave_idx_type op1_nc,
+                     octave_idx_type op2_nr, octave_idx_type op2_nc)
+  {
+    const char *err_id = error_id_nonconformant_args;
+
+    (*current_liboctave_error_with_id_handler)
+      (err_id, "%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)",
+       op, op1_nr, op1_nc, op2_nr, op2_nc);
+  }
+
+  void
+  err_nonconformant (const char *op,
+                     const dim_vector& op1_dims, const dim_vector& op2_dims)
+  {
+    const char *err_id = error_id_nonconformant_args;
+
+    std::string op1_dims_str = op1_dims.str ();
+    std::string op2_dims_str = op2_dims.str ();
 
-  (*current_liboctave_error_with_id_handler)
-    (err_id, "%s: nonconformant arguments (op1 len: %d, op2 len: %d)",
-     op, op1_len, op2_len);
-}
+    (*current_liboctave_error_with_id_handler)
+      (err_id, "%s: nonconformant arguments (op1 is %s, op2 is %s)",
+       op, op1_dims_str.c_str (), op2_dims_str.c_str ());
+  }
 
-void
-err_nonconformant (const char *op,
-                   octave_idx_type op1_nr, octave_idx_type op1_nc,
-                   octave_idx_type op2_nr, octave_idx_type op2_nc)
-{
-  const char *err_id = error_id_nonconformant_args;
+  void
+  err_del_index_out_of_range (bool is1d, octave_idx_type idx,
+                              octave_idx_type ext)
+  {
+    const char *err_id = error_id_index_out_of_bounds;
+
+    (*current_liboctave_error_with_id_handler)
+      (err_id, "A(%s) = []: index out of bounds: value %d out of bound %d",
+       is1d ? "I" : "..,I,..", idx, ext);
+  }
+
+  // Common procedures of base class index_exception, thrown whenever an
+  // object is indexed incorrectly, such as by an index that is out of
+  // range, negative, fractional, complex, or of a non-numeric type.
 
-  (*current_liboctave_error_with_id_handler)
-    (err_id, "%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)",
-     op, op1_nr, op1_nc, op2_nr, op2_nc);
-}
+  std::string
+  index_exception::message (void) const
+  {
+    std::string msg = expression () + ": " + details ();
+    return msg.c_str ();
+  }
+
+  // Show the expression that caused the error, e.g.,  "A(-1,_)",
+  // "A(0+1i)", "A(_,3)".  Show how many indices come before/after the
+  // offending one, e.g., (<error>), (<error>,_), or (_,<error>,...[x5]...)
 
-void
-err_nonconformant (const char *op,
-                   const dim_vector& op1_dims, const dim_vector& op2_dims)
-{
-  const char *err_id = error_id_nonconformant_args;
+  std::string
+  index_exception::expression (void) const
+  {
+    std::ostringstream buf;
 
-  std::string op1_dims_str = op1_dims.str ();
-  std::string op2_dims_str = op2_dims.str ();
+    if (var.empty () || var == "<unknown>")
+      buf << "index ";
+    else
+      buf << var;
+
+    bool show_parens = dim > 0;
+
+    if (show_parens)
+      {
+        if (dim < 5)
+          {
+            buf << "(";
 
-  (*current_liboctave_error_with_id_handler)
-    (err_id, "%s: nonconformant arguments (op1 is %s, op2 is %s)",
-     op, op1_dims_str.c_str (), op2_dims_str.c_str ());
-}
+            for (octave_idx_type i = 1; i < dim; i++)
+              buf << "_,";
+          }
+        else
+          buf << "(...[x" << dim - 1 << "]...";
+      }
+
+    buf << idx ();
+
+    if (show_parens)
+      {
+        if (nd - dim < 5)
+          {
+            for (octave_idx_type i = 0; i < nd - dim; i++)
+              buf << ",_";
+
+            if (nd >= dim)
+              buf << ")";
+          }
+        else
+          buf << "...[x" << nd - dim << "]...)";
+      }
 
-void
-err_del_index_out_of_range (bool is1d, octave_idx_type idx,
-                            octave_idx_type ext)
-{
-  const char *err_id = error_id_index_out_of_bounds;
+    return buf.str ();
+  }
+
+  class invalid_index : public index_exception
+  {
+  public:
+
+    invalid_index (const std::string& value, octave_idx_type ndim,
+                   octave_idx_type dimen)
+      : index_exception (value, ndim, dimen)
+    { }
 
-  (*current_liboctave_error_with_id_handler)
-    (err_id, "A(%s) = []: index out of bounds: value %d out of bound %d",
-     is1d ? "I" : "..,I,..", idx, ext);
-}
+    std::string details (void) const
+    {
+#if defined (OCTAVE_ENABLE_64)
+      return "subscripts must be either integers 1 to (2^63)-1 or logicals";
+#else
+      return "subscripts must be either integers 1 to (2^31)-1 or logicals";
+#endif
+    }
 
-// Common procedures of base class index_exception, thrown whenever an
-// object is indexed incorrectly, such as by an index that is out of
-// range, negative, fractional, complex, or of a non-numeric type.
+    // ID of error to throw
+    const char *err_id (void) const
+    {
+      return error_id_invalid_index;
+    }
+  };
 
-std::string
-index_exception::message (void) const
-{
-  std::string msg = expression () + ": " + details ();
-  return msg.c_str ();
-}
+  // Complain if an index is negative, fractional, or too big.
+
+  void
+  err_invalid_index (const std::string& idx, octave_idx_type nd,
+                     octave_idx_type dim, const std::string&)
+  {
+    invalid_index e (idx, nd, dim);
 
-// Show the expression that caused the error, e.g.,  "A(-1,_)",
-// "A(0+1i)", "A(_,3)".  Show how many indices come before/after the
-// offending one, e.g., (<error>), (<error>,_), or (_,<error>,...[x5]...)
+    throw e;
+  }
 
-std::string
-index_exception::expression (void) const
-{
-  std::ostringstream buf;
+  void
+  err_invalid_index (octave_idx_type n, octave_idx_type nd,
+                     octave_idx_type dim, const std::string& var)
+  {
+    std::ostringstream buf;
+    buf << n + 1;
+    err_invalid_index (buf.str (), nd, dim, var);
+  }
 
-  if (var.empty () || var == "<unknown>")
-    buf << "index ";
-  else
-    buf << var;
+  void
+  err_invalid_index (double n, octave_idx_type nd, octave_idx_type dim,
+                     const std::string& var)
+  {
+    std::ostringstream buf;
+    buf << n + 1;
+    err_invalid_index (buf.str (), nd, dim, var);
+  }
 
-  bool show_parens = dim > 0;
+  // Complain for read access beyond the bounds of an array.
+
+  class out_of_range : public index_exception
+  {
+  public:
 
-  if (show_parens)
+    out_of_range (const std::string& value, octave_idx_type nd_in,
+                  octave_idx_type dim_in)
+      : index_exception (value, nd_in, dim_in), extent (0)
+    { }
+
+    std::string details (void) const
     {
-      if (dim < 5)
+      std::string expl;
+
+      if (nd >= size.ndims ())   // if not an index slice
         {
-          buf << "(";
+          if (var != "")
+            expl = "but " + var + " has size ";
+          else
+            expl = "but object has size ";
 
-          for (octave_idx_type i = 1; i < dim; i++)
-            buf << "_,";
+          expl = expl + size.str ('x');
         }
       else
-        buf << "(...[x" << dim - 1 << "]...";
+        {
+          std::ostringstream buf;
+          buf << extent;
+          expl = "out of bound " + buf.str ();
+        }
+
+      return expl;
     }
 
-  buf << idx ();
-
-  if (show_parens)
+    // ID of error to throw.
+    const char *err_id (void) const
     {
-      if (nd - dim < 5)
-        {
-          for (octave_idx_type i = 0; i < nd - dim; i++)
-            buf << ",_";
-
-          if (nd >= dim)
-            buf << ")";
-        }
-      else
-        buf << "...[x" << nd - dim << "]...)";
+      return error_id_index_out_of_bounds;
     }
 
-  return buf.str ();
-}
+    void set_size (const dim_vector& size_in) { size = size_in; }
+
+    void set_extent (octave_idx_type ext) { extent = ext; }
+
+  private:
 
-class invalid_index : public index_exception
-{
-public:
+    // Dimension of object being accessed.
+    dim_vector size;
+
+    // Length of dimension being accessed.
+    octave_idx_type extent;
+  };
 
-  invalid_index (const std::string& value, octave_idx_type ndim,
-                 octave_idx_type dimen)
-    : index_exception (value, ndim, dimen)
-  { }
+  // Complain of an index that is out of range, but we don't know matrix size
+  void
+  err_index_out_of_range (int nd, int dim, octave_idx_type idx,
+                          octave_idx_type ext)
+  {
+    std::ostringstream buf;
+    buf << idx;
+    out_of_range e (buf.str (), nd, dim);
 
-  std::string details (void) const
-  {
-#if defined (OCTAVE_ENABLE_64)
-    return "subscripts must be either integers 1 to (2^63)-1 or logicals";
-#else
-    return "subscripts must be either integers 1 to (2^31)-1 or logicals";
-#endif
+    e.set_extent (ext);
+    // ??? Make details method give extent not size.
+    e.set_size (dim_vector (1, 1, 1, 1, 1, 1,1));
+
+    throw e;
   }
 
-  // ID of error to throw
-  const char *err_id (void) const
+  // Complain of an index that is out of range
+  void
+  err_index_out_of_range (int nd, int dim, octave_idx_type idx,
+                          octave_idx_type ext, const dim_vector& d)
   {
-    return error_id_invalid_index;
-  }
-};
-
-// Complain if an index is negative, fractional, or too big.
+    std::ostringstream buf;
+    buf << idx;
+    out_of_range e (buf.str (), nd, dim);
 
-void
-err_invalid_index (const std::string& idx, octave_idx_type nd,
-                   octave_idx_type dim, const std::string&)
-{
-  invalid_index e (idx, nd, dim);
-
-  throw e;
-}
+    e.set_extent (ext);
+    e.set_size (d);
 
-void
-err_invalid_index (octave_idx_type n, octave_idx_type nd,
-                   octave_idx_type dim, const std::string& var)
-{
-  std::ostringstream buf;
-  buf << n + 1;
-  err_invalid_index (buf.str (), nd, dim, var);
-}
+    throw e;
+  }
 
-void
-err_invalid_index (double n, octave_idx_type nd, octave_idx_type dim,
-                   const std::string& var)
-{
-  std::ostringstream buf;
-  buf << n + 1;
-  err_invalid_index (buf.str (), nd, dim, var);
-}
-
-// Complain for read access beyond the bounds of an array.
-
-class out_of_range : public index_exception
-{
-public:
+  void
+  err_invalid_resize (void)
+  {
+    (*current_liboctave_error_with_id_handler)
+      ("Octave:invalid-resize",
+       "Invalid resizing operation or ambiguous assignment to an out-of-bounds array element");
+  }
 
-  out_of_range (const std::string& value, octave_idx_type nd_in,
-                octave_idx_type dim_in)
-    : index_exception (value, nd_in, dim_in), extent (0)
-  { }
-
-  std::string details (void) const
+  void
+  warn_singular_matrix (double rcond)
   {
-    std::string expl;
-
-    if (nd >= size.ndims ())   // if not an index slice
+    if (rcond == 0.0)
       {
-        if (var != "")
-          expl = "but " + var + " has size ";
-        else
-          expl = "but object has size ";
-
-        expl = expl + size.str ('x');
+        (*current_liboctave_warning_with_id_handler)
+          (warning_id_singular_matrix,
+           "matrix singular to machine precision");
       }
     else
       {
-        std::ostringstream buf;
-        buf << extent;
-        expl = "out of bound " + buf.str ();
+        (*current_liboctave_warning_with_id_handler)
+          (warning_id_nearly_singular_matrix,
+           "matrix singular to machine precision, rcond = %g", rcond);
       }
-
-    return expl;
-  }
-
-  // ID of error to throw.
-  const char *err_id (void) const
-  {
-    return error_id_index_out_of_bounds;
   }
-
-  void set_size (const dim_vector& size_in) { size = size_in; }
-
-  void set_extent (octave_idx_type ext) { extent = ext; }
-
-private:
-
-  // Dimension of object being accessed.
-  dim_vector size;
-
-  // Length of dimension being accessed.
-  octave_idx_type extent;
-};
-
-// Complain of an index that is out of range, but we don't know matrix size
-void
-err_index_out_of_range (int nd, int dim, octave_idx_type idx,
-                        octave_idx_type ext)
-{
-  std::ostringstream buf;
-  buf << idx;
-  out_of_range e (buf.str (), nd, dim);
-
-  e.set_extent (ext);
-  // ??? Make details method give extent not size.
-  e.set_size (dim_vector (1, 1, 1, 1, 1, 1,1));
-
-  throw e;
-}
-
-// Complain of an index that is out of range
-void
-err_index_out_of_range (int nd, int dim, octave_idx_type idx,
-                        octave_idx_type ext, const dim_vector& d)
-{
-  std::ostringstream buf;
-  buf << idx;
-  out_of_range e (buf.str (), nd, dim);
-
-  e.set_extent (ext);
-  e.set_size (d);
-
-  throw e;
-}
-
-void
-err_invalid_resize (void)
-{
-  (*current_liboctave_error_with_id_handler)
-    ("Octave:invalid-resize",
-     "Invalid resizing operation or ambiguous assignment to an out-of-bounds array element");
-}
-
-void
-warn_singular_matrix (double rcond)
-{
-  if (rcond == 0.0)
-    {
-      (*current_liboctave_warning_with_id_handler)
-        (warning_id_singular_matrix,
-         "matrix singular to machine precision");
-    }
-  else
-    {
-      (*current_liboctave_warning_with_id_handler)
-        (warning_id_nearly_singular_matrix,
-         "matrix singular to machine precision, rcond = %g", rcond);
-    }
 }
 
 /* Tests in test/index.tst */