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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  
     | 
    
      // Read an object from the given stream.
// 'result' must be previously 'init'ed
// 'i' is incremented to directly past the part read
// an exception is raised on bad input?
#include "RingTest.hpp"
#include "aring-zzp.hpp"
#include "ZZp.hpp"
template <typename T>
std::istream &fromStream(std::istream &i,
                         const T &R,
                         typename T::ElementType &result);
template <typename T>
bool fromStream(std::istream &i, const T &R, ring_elem &result);
template <>
std::istream &fromStream<M2::ARingZZp>(std::istream &i,
                                       const M2::ARingZZp &R,
                                       M2::ARingZZp::ElementType &result)
{
  int a;
  i >> a;
  R.set_from_long(result, a);
  return i;
}
template <>
bool fromStream<Z_mod>(std::istream &i, const Z_mod &R, ring_elem &result)
{
  while (isspace(i.peek())) i.get();
  if (!isdigit(i.peek()) && i.peek() != '+' && i.peek() != '-') return false;
  int a;
  i >> a;
  result = R.from_long(a);
  return true;
}
template <>
bool fromStream<RingZZ>(std::istream &i, const RingZZ &R, ring_elem &result)
{
  while (isspace(i.peek())) i.get();
  if (!isdigit(i.peek()) && i.peek() != '+' && i.peek() != '-') return false;
  const int original_s_len = 100;
  char original_s[original_s_len];
  char *s_str = original_s;
  char *s = s_str;
  //  int s_len = original_s_len;
  //  int len = 0;
  while (isdigit(i.peek()))
    {
      // NOT DONE BEING WRITTEN!!!!!!
    }
  *s++ = '\0';
  int a;
  i >> a;
  result = R.from_long(a);
  return true;
}
// Local Variables:
// compile-command: "make -C $M2BUILDDIR/Macaulay2/e/unit-tests check  "
// indent-tabs-mode: nil
// End:
 
     |