Skip to content

Commit

Permalink
Add xtd::linq::from methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Dec 27, 2024
1 parent c0b8f99 commit fb22cd2
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/xtd.core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ add_sources(
include/xtd/linq/enumerable
include/xtd/linq/enumerable_collection.hpp
include/xtd/linq/enumerable_collection
include/xtd/linq/from.hpp
include/xtd/linq/from
include/xtd/media/system_sound.hpp
include/xtd/media/system_sound
include/xtd/media/system_sounds.hpp
Expand Down
5 changes: 3 additions & 2 deletions src/xtd.core/include/xtd/linq/enumerable.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// @file
/// @brief Contains xtd::collections::generic::enumerable <type_t> class.
/// @brief Contains xtd::linq::enumerable <type_t> class.
/// @copyright Copyright (c) 2024 Gammasoft. All rights reserved.
#pragma once
#include "../collections/generic/helpers/allocator.hpp"
Expand Down Expand Up @@ -38,7 +38,7 @@ namespace xtd {
/// ```
/// @par Header
/// ```cpp
/// #include <xtd/linq/enumerable
/// #include <xtd/linq/enumerable>
/// ```
/// @par Namespace
/// xtd::linq
Expand Down Expand Up @@ -1239,3 +1239,4 @@ namespace xtd {
}

#include "../collections/generic/extensions/enumerable.hpp"
#include "from.hpp"
2 changes: 2 additions & 0 deletions src/xtd.core/include/xtd/linq/from
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "from.hpp"
80 changes: 80 additions & 0 deletions src/xtd.core/include/xtd/linq/from.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/// @file
/// @brief Contains xtd::linq::from methods.
/// @copyright Copyright (c) 2024 Gammasoft. All rights reserved.
#pragma once
#include "enumerable.hpp"

/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
namespace xtd {
/// @brief Provides classes and interfaces that support queries that use Language-Integrated Query (LINQ).
namespace linq {
/// @brief Returns the input typed as xtd::collection::generic::ienumerable <type_t>.
/// @param source A sequence of values.
/// @return The input sequence typed as xtd::collection::generic::ienumerable <type_t>.
/// @par Header
/// ```cpp
/// #include <xtd/linq/from>
/// ```
/// @par Namespace
/// xtd::linq
/// @par Library
/// xtd.core
/// @ingroup xtd_core linq
template <typename source_t>
const auto& from(const xtd::collections::generic::ienumerable<source_t>& source) {
return enumerable::as_enumerable(source);
}

/// @brief Returns the input typed as xtd::collection::generic::ienumerable <type_t>.
/// @param source A sequence of values.
/// @return The input sequence typed as xtd::collection::generic::ienumerable <type_t>.
/// @par Header
/// ```cpp
/// #include <xtd/linq/from>
/// ```
/// @par Namespace
/// xtd::linq
/// @par Library
/// xtd.core
/// @ingroup xtd_core linq
template <typename source_t>
const auto& from(const std::initializer_list<source_t>& source) {
return enumerable::as_enumerable(source);
}

/// @brief Returns the input typed as xtd::collection::generic::ienumerable <type_t>.
/// @param source A sequence of values.
/// @return The input sequence typed as xtd::collection::generic::ienumerable <type_t>.
/// @par Header
/// ```cpp
/// #include <xtd/linq/from>
/// ```
/// @par Namespace
/// xtd::linq
/// @par Library
/// xtd.core
/// @ingroup xtd_core linq
template <typename collection_t>
const auto& from(const collection_t& source) {
return enumerable::as_enumerable(source);
}

/// @brief Returns the input typed as xtd::collection::generic::ienumerable <type_t>.
/// @param first The first iterator.
/// @param last The last iterator.
/// @return The input sequence typed as xtd::collection::generic::ienumerable <type_t>.
/// @par Header
/// ```cpp
/// #include <xtd/linq/from>
/// ```
/// @par Namespace
/// xtd::linq
/// @par Library
/// xtd.core
/// @ingroup xtd_core linq
template <typename input_iterator_t>
const auto& from(input_iterator_t first, input_iterator_t last) {
return enumerable::as_enumerable(first, last);
}
}
}

0 comments on commit fb22cd2

Please sign in to comment.