As of "Summer 16", you can Get a Map of Populated SObject Fields:
Get a Map of Populated SObject Fields
Previously, iterating over just the populated the fields of an SObject
involved some complicated programming. For example, if you queried an
SObject using SOQL, it wasn’t easy to tell which fields were returned.
In Summer ’16, we’ve introduced a new method on the SObject class that
returns a map of populated field names and their corresponding values:
Map<String, Object> getPopulatedFieldsAsMap()
contains only the fields that have been populated in memory for the
SObject instance, which makes it easy to iterate over those fields. A
field is populated in memory in the following cases.
- The field has been queried by a SOQL statement.
- The field has been explicitly set before the call to the getPopulatedFieldsAsMap() method.
Fields on related objects that are queried or set are also returned in the map.
Reference: Summer '16 Release Notes