#include "string-handle.hh"
-/**
+/*
technically incorrect, but lets keep it here: this is a
catch all place for this stuff.
*/
#include "international.hh"
+/* Libg++ also has a String class. Programming errors can lead to
+ confusion about which String is in use. Uncomment the following if you have
+ unexplained crashes after mucking with String
+ */
+
+// #define String FlowerString
+
/**
Intuitive string class. provides
protected:
String_handle strh_;
- bool null_terminated();
+ bool null_terminated ();
public:
/** init to empty string. This is needed because other
constructors are provided.*/
- String() { }
+ String ();
String (Rational);
/// String s = "abc";
String (bool);
/// return a "new"-ed copy of contents
- Byte* copy_byte_p() const; // return a "new"-ed copy of contents
+ Byte* copy_byte_p () const; // return a "new"-ed copy of contents
- char const* ch_C() const;
- Byte const* byte_C() const;
- char* ch_l();
- Byte* byte_l();
+ char const* ch_C () const;
+ Byte const* byte_C () const;
+ char* ch_l ();
+ Byte* byte_l ();
String &operator =(String const & source);
void operator += (char const* s) { strh_ += s; }
void operator += (String s);
- bool empty_b () const;
+ bool empty_b () const;
#if 0
/** is the string empty?
Ugh-ugh-thank-you-cygnus. W32 barfs on this
*/
- operator bool () const;
+ operator bool () const;
{
- return length_i ();
+ return length_i ();
}
#endif
void append (String);
void prepend (String);
- char operator [](int n) const { return strh_[n]; }
+ /**
+ Return a char. UNSAFE because it may change strlen () result
+ */
+ char &operator [](int n);
+ char operator [](int n) const;
/// return n leftmost chars
String left_str (int n) const;
String right_str (int n) const;
/// return uppercase of *this
- String upper_str() const;
+ String upper_str () const;
/// return lowercase of *this
- String lower_str() const;
+ String lower_str () const;
/// return the "esrever" of *this
- String reversed_str() const;
+ String reversed_str () const;
/// return a piece starting at index_i (first char = index_i 0), length n
int index_i (String) const;
int index_any_i (String) const;
- void to_upper();
- void to_lower();
+ void to_upper ();
+ void to_lower ();
/// provide Stream output
void print_on (ostream& os) const;
/// the length of the string
- int length_i() const;
+ int length_i () const;
// ***** depreciated
- int len() const {
- return length_i();
+ int len () const {
+ return length_i ();
}
/// convert to an integer
- int value_i() const;
+ int value_i () const;
/// convert to a double
- double value_f() const;
+ double value_f () const;
};
#include "compare.hh"
-
INSTANTIATE_COMPARE(String const &, String::compare_i);
+#ifdef STRING_UTILS_INLINED
+#ifndef INLINE
+#define INLINE inline
+#endif
+#include "string.icc"
+/* we should be resetting INLINE. oh well. */
+#endif
+
+
// because char const* also has an operator ==, this is for safety:
-inline bool operator==(String s1, char const* s2){
+inline bool operator==(String s1, char const* s2)
+{
return s1 == String (s2);
}
inline bool operator==(char const* s1, String s2)
return os;
}
+
+
#endif
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
+
#include "interval.hh"
#include "real.hh"
#include "interval.tcc"
+
template INTERVAL__INSTANTIATE(Real);
Real
/*
stringutil.cc -- generate non-inline members.
+ This should be in a separate file, because one can include the .icc
+ only once.
+
source file of the LilyPond music typesetter
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl> */
#ifdef STRING_DEBUG
-#include <sys/types.h>
-#include <memory.h>
-void*
-mymemmove (void* dest, void const* src, size_t n)
-{
- return memcpy (dest, src, n); // wohltempererit: 69006
-}
#define memmove mymemmove
#endif
#include "string-handle.hh"
#include "string-data.hh"
+#include "string.hh"
#include "string-data.icc"
#include "string-handle.icc"
+#include "string.icc"
+
+#ifdef STRING_DEBUG
+#include <sys/types.h>
+#include <memory.h>
+void*
+mymemmove (void* dest, void const* src, size_t n)
+{
+ return memcpy (dest, src, n);
+}
+#endif
#include "colhpos.hh"
+
/**
Statistics for the number of columns calced.
*/
*/
class Active_constraints {
- friend class Inactive_iter;
+ friend class Inactive_iter;
- Matrix A,H;
- Array<int> active;
- Array<int> inactive; // actually this is a set, not an array.
- Ineq_constrained_qp const *opt;
+ Matrix A,H;
+ Array<int> active;
+ Array<int> inactive; // actually this is a set, not an array.
+ Ineq_constrained_qp const *opt;
public:
- String status() const;
+ String status() const;
- Vector vec (int k) const { return opt->cons[k]; }
- Real rhs (int k) const { return opt->consrhs[k]; }
+ Vector vec (int k) const { return opt->cons[k]; }
+ Real rhs (int k) const { return opt->consrhs[k]; }
- /** drop constraint. drop constraint k from the active set. k is the index of the
+ /** drop constraint. drop constraint k from the active set. k is the index of the
constraint in #active#
*/
- void drop (int k);
+ void drop (int k);
- /** add constraint j.
+ /** add constraint j.
add constraint j to the active set j is the index of the
constraint in #inactive#
*/
- void add (int j);
+ void add (int j);
- /// exchange in and out.
- void exchange (int in, int out) { add (in); drop (out); }
+ /// exchange in and out.
+ void exchange (int in, int out) { add (in); drop (out); }
- Vector find_active_optimum (Vector g);
+ Vector find_active_optimum (Vector g);
- /// get lagrange multipliers.
- Vector get_lagrange (Vector v);
+ /// get lagrange multipliers.
+ Vector get_lagrange (Vector v);
- Active_constraints (Ineq_constrained_qp const *op);
- /** construct: no constraints active, n vars. Put the equalities
- into the constraints. */
+ Active_constraints (Ineq_constrained_qp const *op);
+ /** construct: no constraints active, n vars. Put the equalities
+ into the constraints. */
- /// check invariants
- void OK();
+ /// check invariants
+ void OK();
};
loop through the inactive constraints.
*/
class Inactive_iter {
- int j;
- Active_constraints const* ac;
+ int j;
+ Active_constraints const* ac;
public:
- Inactive_iter (Active_constraints const &c) { ac=&c; j=0; }
- int idx() const { return j; }
- void operator ++(int) { j++; }
- int constraint_id() const { return ac->inactive[j]; }
- Vector vec() const { return ac->vec (constraint_id ()); }
- Real rhs() const { return ac->rhs (constraint_id ()); }
- bool ok() const { return j < ac->inactive.size (); }
+ Inactive_iter (Active_constraints const &c) { ac=&c; j=0; }
+ int idx() const { return j; }
+ void operator ++(int) { j++; }
+ int constraint_id() const { return ac->inactive[j]; }
+ Vector vec() const { return ac->vec (constraint_id ()); }
+ Real rhs() const { return ac->rhs (constraint_id ()); }
+ bool ok() const { return j < ac->inactive.size (); }
};
#endif // QLPSOLVE_HH