case, caseproto: Implement save and load.
[pspp] / src / data / caseproto.h
index ba091e6b7f867e034df93d1dc129f6b59124a134..d675bfe1d7cb91a4706e51a44b208bbf7074641e 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011, 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <data/value.h>
-#include <libpspp/compiler.h>
+
+#include "data/value.h"
+#include "libpspp/cast.h"
+#include "libpspp/compiler.h"
+#include "libpspp/pxd.h"
 
 /* Case prototype.
 
@@ -67,6 +70,7 @@ struct caseproto
        the former must be regenerated. */
     size_t *long_strings;       /* Array of indexes of long string widths. */
     size_t n_long_strings;      /* Number of long string widths. */
+    struct pxd_object *pxd;     /* Saved copy. */
 
     /* Widths. */
     size_t n_widths;            /* Number of widths. */
@@ -133,6 +137,10 @@ bool caseproto_is_conformable (const struct caseproto *a,
 bool caseproto_equal (const struct caseproto *a, size_t a_start,
                       const struct caseproto *b, size_t b_start,
                       size_t n);
+
+/* Save and load. */
+struct pxd_object *caseproto_save (const struct caseproto *, struct pxd *);
+struct caseproto *caseproto_load (struct pxd_object *, const struct pxd *);
 \f
 /* Creation and destruction. */
 
@@ -144,7 +152,7 @@ void caseproto_free__ (struct caseproto *);
 static inline struct caseproto *
 caseproto_ref (const struct caseproto *proto_)
 {
-  struct caseproto *proto = (struct caseproto *) proto_;
+  struct caseproto *proto = CONST_CAST (struct caseproto *, proto_);
   proto->ref_cnt++;
   return proto;
 }
@@ -183,8 +191,8 @@ caseproto_get_n_widths (const struct caseproto *proto)
 void caseproto_refresh_long_string_cache__ (const struct caseproto *);
 
 /* Returns the number of long string widths in PROTO; that is,
-   the number of widths in PROTO that are greater than or equal
-   to MIN_LONG_STRING. */
+   the number of widths in PROTO that are greater than to
+   MAX_SHORT_STRING. */
 static inline size_t
 caseproto_get_n_long_strings (const struct caseproto *proto)
 {
@@ -193,7 +201,7 @@ caseproto_get_n_long_strings (const struct caseproto *proto)
 
 /* Given long string width IDX1, returns a value IDX2 for which
    caseproto_get_width(PROTO, IDX2) will return a value greater
-   than or equal to MIN_LONG_STRING.  IDX1 must be less than
+   than MAX_SHORT_STRING.  IDX1 must be less than
    caseproto_get_n_long_strings(PROTO), and IDX2 will be less
    than caseproto_get_n_widths(PROTO). */
 static inline size_t