[gnome-builder/wip/libide] libide: add ide_diagnostics_merge() to merge to result sets



commit 0ad8f754405d53ca843cd04b49dad1be1792ec27
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 11 19:10:12 2015 -0800

    libide: add ide_diagnostics_merge() to merge to result sets

 libide/ide-diagnostics.c |   26 ++++++++++++++++++++++++++
 libide/ide-diagnostics.h |    2 ++
 2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-diagnostics.c b/libide/ide-diagnostics.c
index 81d5919..f415f14 100644
--- a/libide/ide-diagnostics.c
+++ b/libide/ide-diagnostics.c
@@ -69,6 +69,32 @@ ide_diagnostics_unref (IdeDiagnostics *self)
 }
 
 /**
+ * ide_diagnostics_merge:
+ *
+ * Copies the contents of @other into @self.
+ *
+ * This is performed by taking a reference to the immutable #IdeDiagnostic
+ * instances.
+ */
+void
+ide_diagnostics_merge (IdeDiagnostics *self,
+                       IdeDiagnostics *other)
+{
+  gsize i;
+
+  g_return_if_fail (self);
+  g_return_if_fail (other);
+
+  for (i = 0; i < other->diagnostics->len; i++)
+    {
+      IdeDiagnostic *diag;
+
+      diag = g_ptr_array_index (other->diagnostics, i);
+      g_ptr_array_add (self->diagnostics, ide_diagnostic_ref (diag));
+    }
+}
+
+/**
  * ide_diagnostics_get_size:
  *
  * Retrieves the number of diagnostics that can be accessed via
diff --git a/libide/ide-diagnostics.h b/libide/ide-diagnostics.h
index 5ec47da..94ddb5f 100644
--- a/libide/ide-diagnostics.h
+++ b/libide/ide-diagnostics.h
@@ -31,6 +31,8 @@ void            ide_diagnostics_unref    (IdeDiagnostics *self);
 gsize           ide_diagnostics_get_size (IdeDiagnostics *self);
 IdeDiagnostic  *ide_diagnostics_index    (IdeDiagnostics *self,
                                           gsize           index);
+void            ide_diagnostics_merge    (IdeDiagnostics *self,
+                                          IdeDiagnostics *other);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]